【发布时间】:2013-06-18 10:56:47
【问题描述】:
我正在编写一个非常愚蠢的程序。
我不知道为什么下面的代码不起作用:
static void Main(string[] args){
<Some silly code>
Console.WriteLine("Please choose the lab you are working on:");
int choose = Console.Read();
<Some more silly code, including 1 Console.writeLine() call >
Console.WriteLine("Enter the DB server location");
string DBServer = Console.ReadLine();
Console.WriteLine("Enter the DB name");
string DBName = Console.ReadLine();
}
当我运行程序时,它从不等待第一个 ReadLine 语句
string DBServer = Console.ReadLine();
它立即打印两行
Enter the DB server location
Enter the DB name
然后读取第二个ReadLine string DBName = Console.ReadLine();
当我检查输入表单用户时,它确实很好地读取了第二个,但是第一个字符串出来为空。
有任何想法吗?
【问题讨论】: