我对这样的C++代码很感兴趣:
while(getline(cin, n))
Run Code Online (Sandbox Code Playgroud)
但我想在C#中做到这一点,但我不知道如何做这样的事情。我有10行输入,它需要在一个字符串中,但Console.ReadLine()它只节省了字符串中的一行。10我的字符串变量必须有10行文本,
例如:
"first line of text\nsecond line\nthird".
Run Code Online (Sandbox Code Playgroud)
有什么办法可以像在 C++ 中那样做这样的事情吗?