Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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).

like image 869
Atomix Avatar asked Sep 19 '09 00:09

Atomix


People also ask

How do I keep the print on the same line in C?

printf("start:\n"); printf("\nline 1. printed");

What is the meaning of \r in C?

'\r' is the carriage return character.

Does C support input and output directly?

The C programming language provides many standard library functions for file input and output.

Can we input string in C?

We can take string input in C using scanf(“%s”, str).


1 Answers

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

like image 138
Esben Skov Pedersen Avatar answered Sep 30 '22 08:09

Esben Skov Pedersen