-4
請幫忙!我運行這個程序並輸入了所有3個輸入,但是最後一個輸入程序代碼不會運行,並且程序剛剛退出!我不知道,因爲我完全按照這本書!最後一條語句不會運行c#!
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);
上月底 –
它運行添加到Console.ReadLine(),只是waaaay太快。 @ TimonPost的解決方案將暫停它,您將能夠看到輸出 – Brian
或從命令行運行它。 –