user4398853
user4398853

Reputation:

C# - string ReadLine without new line


Can I do ReadLine in C# (I wanna read to string) without that invisible "\n" just before ReadLine?

I wanna this to look like that:

Type name:
$> (user types here)

But while using ReadLine, I get this:

Type name:
$>
(user types here).

How can I change cursor position to go back line?

Upvotes: 1

Views: 2708

Answers (2)

Jonnus
Jonnus

Reputation: 3028

How are you writing the text to prompt the user? For this behavior you should be using Console.Write(), not .WriteLine() to leave the cursor at the end of the string written to the console.

See also this article explaining it further

Upvotes: 1

Life is good
Life is good

Reputation: 418

maybe you should consider Console.SetCursorPosition

Upvotes: 0

Related Questions