views:

229

answers:

2

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?

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

+6  A: 

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

Esben Skov Pedersen
Oh. That fixes it, thanks.
Atomix
If it's a correct answer that works for you, then click the little tick on the left to accept it as the correct answer. It means the efforts of the commenter are recognised in reputation and makes it easier for people scanning for answers to see which the correct one is.
ICR
+4  A: 

It would be

Console.Write("Input a number: ");

// It will return the entire string after the user hits enter
string theNumber = Console.ReadLine();

int number = 0;

if(int.TryParse(theNumber, out number))
{
  // Do something with the number
}
David Basarab