你如何等待在同一Console.WriteLine()线路输入? [英] How do you wait for input on the same Console.WriteLine() line?
本文介绍了你如何等待在同一Console.WriteLine()线路输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想提一个问题,如:
你叫什么名字?乔
块引用>
我将如何做到这一点使用
Console.WriteLine
也等待在同一行,而不是它的响应被分为:
你叫什么名字
$ b? $ b乔
块引用>
解决方案使用Console.Write代替,所以没有换行写
Console.Write(你叫什么名字?);
变种名称=到Console.ReadLine();
I want to pose a question such as:
What is your name? Joe
How would I accomplish this using
Console.WriteLine
to also wait for the response on that same line instead of it being broken into:What is your name?
Joe
解决方案Use Console.Write instead, so there's no newline written:
Console.Write("What is your name? "); var name = Console.ReadLine();
这篇关于你如何等待在同一Console.WriteLine()线路输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文