87.
You need method that loops through a string of numbers and adds them together.
Will the following method return a correct sum of the numbers?
public int Add(string s)
{
int result = 0;
for (int i = 0; i < s.Length; i++)
{
result += Convert.ToInt32(s[i]);
}
return result;
}
View Description
Convert.ToInt32(s[i]) does not convert the string at the specified index to a number. It converts the Unicode char to it's 32-bit signed integer value. To make this work, the ToInt32 method would need to be passed a string - Convert.ToInt32(s[i].ToString()).