Is there anyway to delete certain parts of a console window using the (Left,Top) coordinates used with Console.SetCursorPosition()?
Could you make a custom method for it?
Silky's comment is the right answer:
For example:
public static void ClearArea(int top, int left, int height, int width)
{
ConsoleColor colorBefore = Console.BackgroundColor;
try
{
Console.BackgroundColor = ConsoleColor.Black;
string spaces = new string(' ', width);
for (int i = 0; i < height; i++)
{
Console.SetCursorPosition(left, top + i);
Console.Write(spaces);
}
}
finally
{
Console.BackgroundColor = colorBefore;
}
}
Note that this will restore the background colour, but not the previous cursor location.
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