string.Last()
returns the char
'1'
.
(string.Last()
返回char
'1'
)
The UTF-16 code for '1'
is 49
and if you add 1
to 49
, you get 50
. ('1'
的UTF-16代码为49
,如果将1
加到49
,则得到50
。)
You have to transform the character to the number it represents, for example with int.Parse()
.
(您必须将字符转换为它表示的数字,例如使用int.Parse()
。)
...
Console.WriteLine(int.Parse(str.Last().ToString()) + 1);
...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…