Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I print a string to the console without a newline at the end?

Tags:

c#

My question is.

what is it you type when you want your answer next to your question in c#

I mean like this but you type the answer next to the question.

string product;

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

product = Console.ReadLine(); 
like image 374
user1152722 Avatar asked Jan 16 '12 21:01

user1152722


People also ask

What method writes to the console window without creating a new line?

Write is used to print data without printing the new line, while Console. WriteLine is used to print data along with printing the new line. Program 1: Example of Console.

How do I print to the next line in console?

If you wish to add a new line to the JavaScript new line console while printing a few words, the \n sign for the new line can be used.

How do you suppress a newline in Python?

In Python 3. x , you can use the optional end="" argument to the print() function to prevent a newline character from being printed.

How do I print a node JS console?

log() function from console class of Node. js is used to display the messages on the console. It prints to stdout with newline. Parameter: This function contains multiple parameters which are to be printed.


2 Answers

Instead of using Console.WriteLine() use Console.Write()

like image 87
Sam I am says Reinstate Monica Avatar answered Sep 22 '22 02:09

Sam I am says Reinstate Monica


I believe you're looking for Console.Write("your text here"); rather than Console.WriteLine("your text here");

like image 30
Nick Heidke Avatar answered Sep 19 '22 02:09

Nick Heidke