Console.readline shows something earlier

I have something like this:

Console.WriteLine("Y =");
Y = Convert.ToInt32(Console.ReadLine());

and it is displayed as follows

Y=
//and here i have to input my value

I want to put my value on the same line

Y= //here to input my value

Any tips?

+4
source share
2 answers

Then you can choose

Console.Write("Y = ");

instead

Console.WriteLine("Y = ");
+4
source

try Console.Write("Y =");

instead

Console.WriteLine("Y = ");

because the script creates a new line, but Write does not.

As described here http://social.msdn.microsoft.com/Forums/vstudio/en-US/5ff3931a-8113-4f8c-a1dd-801d8e6db0e5/whats-the-difference-between-write-and-writeline : -

The write procedure writes the text and places the carriage after the last character in the text.

Console.Write ("Thank you") -

: )

WriteLine rocedure line (, MS WORD)

Console.WriteLine( "" ) -

:

| → .

)

Environment.NewLine . (,\n )

Console.Write( "Thank" + Environment.NewLine + "you" ) -

:

)

+2

Source: https://habr.com/ru/post/1544138/


All Articles