How can a line in the console be cleared in C#?
I know how to place the cursor at the beginning of a line:
Console.SetCursorPosition(0, Console.CursorTop
Once the last space of a console buffer row is used, the console cursor automatically jumps to the next line.
Reset cursor back onto the line that was just cleared
while (true)
{
Console.Write(".");
if (Console.CursorLeft + 1 >= Console.BufferWidth)
{
Console.SetCursorPosition(0, Console.CursorTop);
Console.Write(Enumerable.Repeat(' ', Console.BufferWidth).ToArray());
Console.SetCursorPosition(0, Console.CursorTop - 1);
}
if (Console.KeyAvailable)
break;
}