Character array
-
I have string array, I converted that one to char array I am trying to access values of character array and trying to convert them to integer. code follows here string rs="999"; char[] rs1=rs.ToCharArray(); int i; int sum=0; for(i=0;i
-
I have string array, I converted that one to char array I am trying to access values of character array and trying to convert them to integer. code follows here string rs="999"; char[] rs1=rs.ToCharArray(); int i; int sum=0; for(i=0;i
GetOn&GetGoing wrote: I am getting the address value... Try the following:
int sum = 0;
int i = 0;
string rs = "999";
char[] rs1 = rs.ToCharArray();
foreach(char c in rs1)
{
i = Convert.ToInt32(c);
sum += 10 * i;
Console.WriteLine(sum.ToString());
}- Nick Parker
My Blog -
I have string array, I converted that one to char array I am trying to access values of character array and trying to convert them to integer. code follows here string rs="999"; char[] rs1=rs.ToCharArray(); int i; int sum=0; for(i=0;i
Why not just: int val=Convert.ToInt32(rs); Marc Latest AAL Article My blog Join my forum!