0
I have an integer value and need to transform it into an array to sum each of the elements individually. I did it as follows (example):
int n = 1230;
string sn = Convert.ToString(n); //converte em string
char[] narr = sn.ToArray(); //converte em array
int t = narr[0] + narr[1]; // realiza a soma e retorna t = 99 (49+50 equivalencia decimal 1 e 2 na tabela ASCII)
Console.WriteLine("\n narr[0] = {0}", narr[0]); // narr[0] = 1
Console.WriteLine("\n narr[1] = {0}", narr[1]); // narr[1] = 2
how to sum the value of each index (t = 1+2)?
Running I can perform the sum, used decision structure I can perform the sum of part or total of the int, but adding value of integers converted into array (using array) is not possible?
– AsAlbu
@Asalbu updated the response
– Rovann Linhalis