小编use*_*206的帖子

在c#中从控制台输入多行

我试图从控制台读取c#中的一些值,然后处理它们.但是我遇到了错误.

控制台的输入是:

Name:ABCD
School:Xyz
Marks:80
 //here the user enters a new line before entering new data again
Name:AB
School:Xyz
Marks:90
//new line again 
Name:AB
School:Xyz
Marks:90
Run Code Online (Sandbox Code Playgroud)

等等.我事先不知道控制台输入的数量......我怎样才能检测到用户已经停止输入和存储输入.

我试过用

string line;
while((line=Console.ReadLine())!=null)
{
  //but here it seems to be an infinite loop 
}
Run Code Online (Sandbox Code Playgroud)

有什么建议

c# command-line input console-application

4
推荐指数
2
解决办法
8752
查看次数

标签 统计

c# ×1

command-line ×1

console-application ×1

input ×1