static void Main(string[] args)
{
int num = 382;
int output = 0;
char[] nlst = num.ToString().ToCharArray();
for (int i = 0; i < nlst.Length; i++)
{
output += nlst[i];
}
Console.WriteLine(output);
Console.ReadLine();
}
输出结果为157,实际应该是13。通过调试我发现char[] nlst的三个元素如下:
[0]51'3',[1]56'8',[2]50'2'
为什么?51、56、50代表什么意思?