I want to know if it is possible to get back to the last line when I'm at the beginning of the next line? (in C# Console, of course)
I mean Console.WriteLine()
cause going to the next line and I want to stay in my line even after pressing enter. (And I think there isn't another way to ReadLine without going to the next line , is there?)
I found that Console.SetCursorPosition()
can be useful, like below:
int x, y;
Console.WriteLine("Please enter the point's coordinates in this form (x,y):");
Console.Write("(");
x = Convert.ToInt32(Console.ReadLine());
Console.SetCursorPosition(x.ToString().Length + 1, Console.CursorTop - 1);
Console.Write(",");
y = Convert.ToInt32(Console.ReadLine());
Console.SetCursorPosition(x.ToString().Length + y.ToString().Length + 2, Console.CursorTop - 1);
Console.WriteLine(")");
This seems to work fine but when I try to change Console.Write("(")
;
into something like Console.Write("Point A=(")
, I need to change the the Console.SetCursorPosition()
arguments every time.
Also it would be very helpful if I could move the cursor to the last character (except spaces) in the console buffer.(I think it would be easy if I could copy a specific line from console into a string.)
Thanks in advance.