Answer the question
In order to leave comments, you need to log in
Need to find the sum of the last and from the end of the third digit of the number 12345689?
I turned it into a character array, but in the end I got a number code instead of the sum, what's the problem?
string bar = "123456789";
char[] barArr = sw.ToCharArray();
int c;
for (int i = 0; i < barArr.Length; i++)
{
int sum = barArr[barArr.Length - 3] + barArr[barArr.Length - 1];
}
Answer the question
In order to leave comments, you need to log in
var sum = (x % 1000)/100 + x % 10;
more
details here https://dotnetfiddle.net/0BhxjK
ps
var sum = (x[x.Length-1] - '0') + (x[x.Length-3] - '0');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question