Clearing a line in the console

后端 未结 4 1649
青春惊慌失措
青春惊慌失措 2021-02-10 10:50

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         


        
4条回答
  •  时光取名叫无心
    2021-02-10 11:16

    After setting the cursor position, you can use backspace:

    do { Console.Write("\b \b"); } while (Console.CursorLeft > 0);
    

提交回复
热议问题