C
C#2y ago
Gotboay

❔ Question.

I'm wondering how to remove all past text in my code.
13 Replies
Keswiik
Keswiik2y ago
Gonna need more context, because I have no clue what you mean by "all past text in my code"
Gotboay
GotboayOP2y ago
like say it writes "hello world!" i want to be able to delete that text afterwards.
Keswiik
Keswiik2y ago
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 line
Keswiik
Keswiik2y ago
if 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 lines
Gotboay
GotboayOP2y ago
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.
Jimmacle
Jimmacle2y ago
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
Gotboay
GotboayOP2y ago
the thing is i don't understand how to do that
Jimmacle
Jimmacle2y ago
you use the method that ded linked the documentation of
Gotboay
GotboayOP2y ago
it turns out all i had to do was "Console.Clear();"
Jimmacle
Jimmacle2y ago
yeah, if you want to nuke literally everything that works
Gotboay
GotboayOP2y ago
thats what i wanted to do but what was the link he sent me for?
Keswiik
Keswiik2y ago
For moving the active cursor position to write over specific text
Accord
Accord2y 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.
Want results from more Discord servers?
Add your server