Console.WriteLine(“在下面输入要转换为科学记数法的值”);Console.WriteLine("~输入程序末尾的任意字母~ \n");
int y = Convert.ToInt32(Console.Read());
Console.WriteLine(y);
if (y >= 1 && y <= 10)
{
Console.WriteLine("val [ {0} ] is in valid form", y);
}
else if (y > 10)
{
Upp(y);
}
else if (y < 1)
{
Low(y);
}
发布于 2019-06-27 03:08:03
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
https://stackoverflow.com/questions/56779368
复制相似问题