请帮忙!我运行了这个程序并输入了所有3个输入,但是最后一个编写的代码不会运行,程序就会退出!我不知道,因为我完全按照这本书!
string userName = "";
int userAge = 0;
int currentYear = 0;
Console.Write("Please enter your name: ");
userName = Console.ReadLine();
Console.Write("Please enter your age: ");
userAge = Convert.ToInt32(Console.ReadLine());
Console.Write("Please enter the current year: ");
currentYear = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Hello World! My name is {0} and I am {1} years old. I was born in {2}.", userName, userAge, currentYear - userAge);
答案 0 :(得分:-3)
在代码末尾添加:
Console.ReadLine();