C
C#14mo ago
Gotboay

❔ Question.

I'm wondering how to remove all past text in my code.
13 Replies
Keswiik
Keswiik14mo ago
Gonna need more context, because I have no clue what you mean by "all past text in my code"
Gotboay
Gotboay14mo ago
like say it writes "hello world!" i want to be able to delete that text afterwards.
Keswiik
Keswiik14mo 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
Keswiik14mo 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
Gotboay14mo 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
Jimmacle14mo 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
Gotboay14mo ago
the thing is i don't understand how to do that
Jimmacle
Jimmacle14mo ago
you use the method that ded linked the documentation of
Gotboay
Gotboay14mo ago
it turns out all i had to do was "Console.Clear();"
Jimmacle
Jimmacle14mo ago
yeah, if you want to nuke literally everything that works
Gotboay
Gotboay14mo ago
thats what i wanted to do but what was the link he sent me for?
Keswiik
Keswiik14mo ago
For moving the active cursor position to write over specific text
Accord
Accord14mo 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
More Posts
❔ Question on how AddDbContext worksI have some beginner question. I'm confused about how ```csharp builder.Services.AddDbContext<Onlin❔ Difficulties with http requests for image(blob) column in mysqlSo i recently learned how to pull basic data from mysql but am struggling to find anything I think iCannot access file because it's being used by another processI am getting the following error when I try to run my program: `System.IO.IOException: 'The process print out all pairs of natural numbers whose sum isequal to the entered number nWrite an algorithm that prints out all pairs of natural numbers whose sum is equal to the entered nu❔ "BLAZOR102: The scoped css file '~\Layout.cshtml.css' was defined but..." How do I fix this error?I've been messing around with ASP.NET and trying to make a new web app, originally I was having issu❔ Unity 3D Urp ProblemsDoes anyone know why when i make a 3d urp project, nothing shows up on my camera? The camera is look✅ im new and i dont get thisi get error cs 1525 unexpected symbol on code line 8 and 16✅ `DllImport` on a dll name only known at runtimeI have a bunch of native dlls that have the same interface (they export the same functions with iden❔ Some theory questions I'm unsure about :)I just have a few questions that I'm unsure about when I was revising for an exam. Sorry if some are✅ [SOLVED] Need help with converting async method to a 'normal' methodI tried a few solutions to be able to call an async method from my Main method but those have failed