I have an integer value and need to transform into an array to do the sum of each of the elements individually. I did this (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 add the value of each index (t = 1 + 2)?