如何在没有换行符的情况下将字符串打印到控制台?

时间:2012-01-16 21:41:17

标签: c#

我的问题是。

如果您希望在c#

中的问题旁边找到答案,那么您输入的内容是什么?

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

string product;

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

product = Console.ReadLine(); 

4 个答案:

答案 0 :(得分:21)

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

答案 1 :(得分:4)

string product;

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

product = Console.ReadLine(); 

答案 2 :(得分:3)

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

答案 3 :(得分:2)

听起来你正试图摆脱换行符。

WriteLine打印换行符 Write没有。