I am currently working on a game that takes place in the console. I need to know how to combine

Console.WriteLine()

and

Console.ReadLine()

into 1 line so that the blinking underscore appears on the same line. Is there any way to do this? Any help is appreciated.

Recommended Answers

All 9 Replies

Not sure but try this:

void tryThis() {
  Console.ReadLine();
  Console.WriteLine();
}
Console.Write(Console.ReadLine());

Try This!!

samuael, that worked perfectly however how would I still write text on that line?

What exactly would you like to do? Can you give us an example?

I would like to write a string (s) to a line in the console. But instead of having the blinking underscore on the next line, I want it next to the string I just wrote to the console. In C++ it would be:

cout << s; cin.ignore();

WriteLine automatically adds a newline character. Write, on the other hand, does not.

Console.Write("");
Console.ReadLine();

Use Console Write or Read instead of WriteLine and ReadLine
The methods with Line add an extra cr char.

Thanks Sodabread, that was exactly what I was looking for. This is just another quick question. Is there anyway I can write some text on to the console, and then change that text to something else?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.