so im taking number input and the im trying to add each digit to an array of int without using any loop
here i got an answer
int[] fNum = Array.ConvertAll(num.ToString().ToArray(),x=>(int)x - 48);
I understand until .toarray(), but I do not understand why it takes a new variable x and the => (int)x - 48.
Could anyone explain this to me?
Because the asci value of 0 is 48 and for 1 it is 49. so to get the char value 1 you need to do 49 - 48 which is equal to 1 and similarly for other numbers.
you should also look in to the documentation of Array.ConvertAll.
It clearly explains the second parameter,
You can also refer to this declaration in the Array class.
Also, have a look to understand lambda operator and the official documentation.