13 Replies
Gonna need more context, because I have no clue what you mean by "all past text in my code"
like say it writes "hello world!" i want to be able to delete that text afterwards.
Well, you don't really 'delete' text in the console. After it is written you would need to write back over it with spaces (empty text)
if you have haven't printed a new line, you can start your next line with (
\r
) (carriage return), which prints at the beginning of the current lineif you are printing a new line (ex:
Console.WriteLine
), you'd need to determine how many lines of text you wrote, adjust the cursor position (https://learn.microsoft.com/en-us/dotnet/api/system.console.setcursorposition?redirectedfrom=MSDN&view=net-7.0#definition), and print that many empty linesConsole.SetCursorPosition(Int32, Int32) Method (System)
Sets the position of the cursor.
thanks for the help
i still don't quite understand, i'm quite new to C# and coding in general so i might need some more elaboration.
think of the console window like a whiteboard
whenever you write something the marker continues from the last place it stopped
if you want to go back and change something, you have to move the marker back over it and write over it
the thing is i don't understand how to do that
you use the method that ded linked the documentation of
it turns out all i had to do was "Console.Clear();"
yeah, if you want to nuke literally everything that works
thats what i wanted to do
but what was the link he sent me for?
For moving the active cursor position to write over specific text
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.