Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# console, Console.Clear problem

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.

like image 1000
user47415 Avatar asked Dec 18 '08 14:12

user47415


1 Answers

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);
}
like image 98
Diadistis Avatar answered Oct 09 '22 11:10

Diadistis