Rewriting characters in command window

2019-02-25 12:04发布

I want to output some characters in C# console application and then rewrite them, thus changing characters in position already occupied in command window. So for for example I could show progress in percentages 10%, 20%, 30% (but in the same place). How can I do that?

2条回答
Summer. ? 凉城
2楼-- · 2019-02-25 12:25

If you print a '\r' character, the cursor will return back to the current line, e.g.

Console.Write("10%\r");
// then..
Console.Write("20%\r");
查看更多
登录 后发表回答