Search code examples
c#consoleuser-input

Input on same line as output in C#


For example:

C:\> Input a number: 60

Where the output would be "Input a number: " and the input would be "60".

How do I get these to be on the same line?

The problem is when I output "Input a number: ", it automatically starts a new line, so the user inputs "60" underneath (on the next line).


Solution

  • Use System.Console.Write instead of System.Console.WriteLine