Clearing a line in the console

后端 未结 4 1539
青春惊慌失措
青春惊慌失措 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:19

    Simplest method would be to move to the start of the line, as you have done, and then write out a string of spaces the same length as the length of the line.

    Console.Write(new String(' ', Console.BufferWidth));
    

提交回复
热议问题