2012-01-16 75 views
7

我的问题是。如何在不使用换行符的情况下将字符串打印到控制台?

你有什么事类型,当你想你的答案你在C#

我的意思是这样,但你键入旁边问题的答案的问题旁边。

string product; 

Console.WriteLine("What is the product you want?"); 

product = Console.ReadLine(); 
+7

用书写()代替的WriteLine()。 – 2012-01-16 21:43:22

+0

请尝试接受你作为答案得到的答案中的最佳解决方案。 – Bastardo 2012-01-17 13:46:40

回答

2

这听起来像你试图摆脱换行。

WriteLine打印换行符。
Write没有。

19

而不是使用Console.WriteLine()使用Console.Write()

3
 string product; 

     Console.Write("What is the product you want?"); 

     product = Console.ReadLine(); 
2

我相信你正在寻找Console.Write("your text here");而不是Console.WriteLine("your text here");

相关问题