Is there a method in C# that will clear the screen and place the cursor at 1,1 in a CLI? I would've thought it would be in System.Console, but I couldn't find anything event remotely like it.
Is there a method in C# that will clear the screen and place the cursor at 1,1 in a CLI? I would've thought it would be in System.Console, but I couldn't find anything event remotely like it.
When I read your post I immediatly thought there must be a System.Console.ClearScreen...
But as it seems, there is no such function. Have a look here for Microsofts suggestion. I hoped they were just kidding, but apparantly they are not
hth
-nv
She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."
When in doubt, read the FAQ.
Then ask a smart question.
interesting how every programmer at some point in time needs to clear the console somehow and yet they just keep making it harder and harder to do
The easiest way is to output blank lines. I believe the number is 25. I might be a little off since I haven't worked with C# in a while (lost the CD I put the SDK on).
The console in .NET is extremely weak. If you want more advanced abilities you'd be better off writing a component that mimics the command prompt. Or just painting a form black and drawing text to it using the Lucida Console font.Code:for (int index = 0; index < 24; index++) { System.Console.WriteLine(""); }
Edit: Stupid code tags don't function in quick post. :P
Last edited by Frobozz; 07-24-2004 at 09:30 PM.
In most cases that would work. The problem is that first of all, the cursor is now at the bottom, and I don't think there's an easy way to position the cursor (like BASIC's Location). Also, you can change the number of lines in the console window when you're the user.