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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Have a look at Writing string at the same position using Console.Write in C# 2.0
- Console.SetCursorPosition Method
- Console.CursorLeft Property
- Console.CursorTop Property
回答2:
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");