+ 1
[Solved] Is there an easier way to test for numbers in Password Validation than explicitly typing each number to test for?
6 Respostas
+ 2
You could use Enumerable.Range()
char[] availableNumbers = Enumerable.Range(48, 57).Select(i => (char)i).ToArray();
+ 2
It's taking the integer values from our Range and casting them to their corresponding Ascii character E.g 48 => '0' , 49 => '1' , 50 => '2' and so on
+ 1
Yes. 'i' is our integer value from the range, and (char)i is changing(type casting) our data type from integer to char. Sorry if it's hard to understand, my technical talk in English isn't the best
0
So I understand that Enumerable.Range(0, 9) would make a range from 0-9, but what does the '.Select(i => (char)i)' do?
0
So 'i' represents the value eg: 45? Or does 'i' represent the index? And why is char in parentheses next to the 'i'?
0
Thank you, that answers my question. ♡Addy♡