在命令窗口中重写字符

发布于 2024-08-23 09:55:14 字数 103 浏览 3 评论 0原文

我想在 C# 控制台应用程序中输出一些字符,然后重写它们,从而更改命令窗口中已占用位置的字符。例如,我可以以 10%、20%、30% 的百分比显示进度(但在同一个地方)。我怎样才能做到这一点?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

别念他 2024-08-30 09:55:14

如果打印'\r'字符,光标将返回到当前行,例如

Console.Write("10%\r");
// then..
Console.Write("20%\r");

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");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文