I am writing a console program in C#.
Is there a way I can use a Console.Clear() to only clear certain things on the console screen?
Here's my issue:
I have a logo (I put it on screen using Console.WriteLine()) and a 2d array which I want to keep constant and clear everything below it.
You could use a custom method to clear parts of the screen...
static void Clear(int x, int y, int width, int height)
{
int curTop = Console.CursorTop;
int curLeft = Console.CursorLeft;
for (; height > 0;)
{
Console.SetCursorPosition(x, y + --height);
Console.Write(new string(' ',width));
}
Console.SetCursorPosition(curLeft, curTop);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With