7

私は完全に困惑しています

string temp = "73";
int tempc0 = Convert.ToInt32(temp[0]);
int tempc1 = Convert.ToInt32(temp[1]);
MessageBox.Show(tempc0 + "*" + tempc1 + "=" + tempc0*tempc1);

私は期待します:7*3=21

しかし、私は受け取ります:55*51=2805

4

7 に答える 7

1

文字を整数に変換すると、Unicode 文字コードが得られます。文字列を整数に変換すると、数値として解析されます。

string temp = "73";
int tempc0 = Convert.ToInt32(temp.Substring(0, 1));
int tempc1 = Convert.ToInt32(temp.Substring(1, 1));
于 2013-03-14T09:01:35.953 に答える