我一直在尝试在C#中使用Console.Read()和Console.ReadLine(),但是得到了奇怪的结果。例如这段代码:
Console.WriteLine("How many students would you like to enter?");
int amount = Console.Read();
Console.WriteLine("{0} {1}", "amount equals", amount);
for (int i=0; i < amount; i++)
{
Console.WriteLine("Input the name of a student");
String StudentName = Console.ReadLine();
Console.WriteLine("the Students name is " + StudentName);
}
在我输入1作为学生数量时,这个程序给出了49的结果,甚至没有让我输入学生姓名。