wtm
wtm

Reputation: 166

c# console writeline after string

So I am wondering, how can I make a console start typing after a string? For example: The console says Username > and i can type after that instead of under.

Example:

How I have it now:

Username >
i type here

How I want it:

Username > i type here

I hope you guys know what I mean, thanks!

Upvotes: 1

Views: 475

Answers (2)

Fᴀʀʜᴀɴ Aɴᴀᴍ
Fᴀʀʜᴀɴ Aɴᴀᴍ

Reputation: 6251

Output your prompt text before Console.Readline():

Console.Write("Username > ");

And the problem you are having is because you use Console.WriteLine() which will append a new line after whatever you tell it to write. So use just Console.Write()

From MSDN:

Console.WriteLine() - Writes the specified data, followed by the current line terminator, to the standard output stream.

Console.Write() - Writes the text representation of the specified value or values to the standard output stream.

Upvotes: 3

adv12
adv12

Reputation: 8551

Use Console.Write() rather than Console.WriteLine()

Upvotes: 3

Related Questions