C
C#9mo ago
Nadekai

❔ How to display text below console.Readline

How do I accomplish this layout?
No description
25 Replies
Pobiega
Pobiega9mo ago
Console.WriteLine(); creates a blank line
Nadekai
Nadekai9mo ago
That's not the problem, the proble is I need to get user input line above. While also displaying the bottom line.
Pobiega
Pobiega9mo ago
how is that a problem?
Nadekai
Nadekai9mo ago
Because I have no idea how to do that
Pobiega
Pobiega9mo ago
Show me your current code
Nadekai
Nadekai9mo ago
There is nothing there.
Pobiega
Pobiega9mo ago
or do you mean printing that line before the readline?
Nadekai
Nadekai9mo ago
Exactly
Thinker
Thinker9mo ago
Write out all the text and then set the cursor position
Pobiega
Pobiega9mo ago
yeah write hi set cursor position write "you msut enter name" set cursor position write "enter your name: " take input
Nadekai
Nadekai9mo ago
uh... how do I do that?
Angius
Angius9mo ago
The specific layout you posted
No description
Angius
Angius9mo ago
No need for any cursor shenanigans Just good ol' Console.Write()
Pobiega
Pobiega9mo ago
nah, they want the "you must enter name" to be printed WHEN its asking for input
Nadekai
Nadekai9mo ago
Yep
Angius
Angius9mo ago
Ah Then, yeah, cursor shenanigans
Pobiega
Pobiega9mo ago
No description
Pobiega
Pobiega9mo ago
thats how you move the cursor around
Nadekai
Nadekai9mo ago
Alright
Pobiega
Pobiega9mo ago
the values are just random numbers, not the ones you need
Nadekai
Nadekai9mo ago
Thanks!
ZacharyPatten
ZacharyPatten9mo ago
it can be easier to store the position you wantthe cursor to be rather than having to manually supply it yourself:
Console.WriteLine("Hello, World!");
Console.Write("Enter some text: ");
var pos = Console.GetCursorPosition();
Console.WriteLine();
Console.WriteLine("some text...");
Console.SetCursorPosition(pos.Left, pos.Top);
string input = Console.ReadLine();
Console.WriteLine("Hello, World!");
Console.Write("Enter some text: ");
var pos = Console.GetCursorPosition();
Console.WriteLine();
Console.WriteLine("some text...");
Console.SetCursorPosition(pos.Left, pos.Top);
string input = Console.ReadLine();
in the above code, it prints all the stuff up until the user input in needed, then it grabs the current cursor position, then prints the rest of the output, then sets the cursor back to the position we captured This way you don't have to manually progam 123 Left, and 123 Top... etc
ZacharyPatten
ZacharyPatten9mo ago
--- however, in general this is not an ideal way to handle input.
No description
ZacharyPatten
ZacharyPatten9mo ago
Console.ReadLine allows long input and wraps text around also, if the user changes the size of the window, they can change the current view changing hte view can cause the text to wrap and thus change cursor positions --- I can suggest some alternatives, but depending on what you are making, spending a lot of time just to have text after a ReadLine might not be worth it
Accord
Accord9mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.