C# 当我在代码中输入一个值时,会使用另一个(假定的ascii)值。例如:输入7,输出55。我怎么修理它?

C# 当我在代码中输入一个值时,会使用另一个(假定的ascii)值。例如:输入7,输出55。我怎么修理它?,c#,C#,Console.WriteLine(“在下面输入要转换为科学符号的值”); Console.WriteLine(“~输入任何字母以结束程序~\n”) int y=Convert.ToInt32(Console.Read()); 控制台写入线(y); 如果(y>=1&&y 10) { Upp(y); } 否则如果(y

Console.WriteLine(“在下面输入要转换为科学符号的值”); Console.WriteLine(“~输入任何字母以结束程序~\n”)

int y=Convert.ToInt32(Console.Read());
控制台写入线(y);
如果(y>=1&&y 10)
{
Upp(y);
}
否则如果(y<1)
{
低(y);
}
Console.Read()读取字符,当在Convert.ToInt32()中使用字符时,它输出ASCII值。使用Console.ReadLine()获取字符串。将字符串与Convert.ToInt32()一起使用时,您将得到所需的结果

Console.WriteLine(Console.Read()); // Input 7 output 55
Console.WriteLine(Console.ReadLine()); // Input 7 output 7

你好,杰克·沃德。欢迎来到StackOverflow。在你的问题中,你没有真正提出任何问题;这只是一个标题和代码示例。如果你可以编辑你的帖子来问你的问题,我相信有人会乐意帮助你。使用像“ASCII值”这样的术语是误导性的。对于文本数据类型,.NET使用Unicode字符集的UTF-16字符编码(Java、JavaScript、VB4/5/6/A/Script等)。
Console.WriteLine(Console.Read()); // Input 7 output 55
Console.WriteLine(Console.ReadLine()); // Input 7 output 7