在 .net 控制台应用程序中显示百分比
我有一个控制台应用程序执行一个漫长的过程。
我正在新行上打印出完成百分比,每完成 1%。
如何让程序在控制台窗口的同一位置打印出完成百分比?
I have a console app that performs a lengthy process.
I am printing out the percent complete on a new line, for every 1% complete.
How can I make the program print out the percent complete in the same location in the console window?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
打印
\r
以返回到行的开头(但不要打印换行符!)例如:
Print
\r
to get back to the start of the line (but don't print a newline!)For example:
您可以使用:
适当地设置位置。
就像这样:
You may use:
To set the position appropriately.
Like so: