2012-01-16 45 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");

相關問題