有没有更好的替代 Console.ReadKey() 的方法?

发布于 2024-07-29 06:19:03 字数 151 浏览 1 评论 0原文

大多数编程书籍都会告诉您使用 Console.ReadKey() 来暂停控制台,但是有更好的选择吗?

Console.WriteLine("Press any key to continue.");
Console.ReadKey();

Most programming books will tell you to use Console.ReadKey() to pause the console, but is there a better alternative?

Console.WriteLine("Press any key to continue.");
Console.ReadKey();

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

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

发布评论

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

评论(3

欲拥i 2024-08-05 06:19:03

您实际上还没有告诉我们您希望实现什么目标。

如果您希望停止输出直到用户选择继续,那么您实际上不会比使用 Console.ReadKey等待按键更好。代码>.

如果您只想暂停输出一段时间,可以使用Thread.Sleep方法,该方法不需要任何人工干预。

You haven't actually told us what you wish to achieve.

If you wish to stop the output until the user chooses to continue, then you're not really going to get much better than just waiting for a key to be pressed using Console.ReadKey.

If you just want to pause the output for a certain amount of time, you can use the Thread.Sleep method, which doesn't require any human intervention.

牛↙奶布丁 2024-08-05 06:19:03

Console.ReadLine() 怎么样:)

How about Console.ReadLine() :)

秋心╮凉 2024-08-05 06:19:03
system("pause");

做同样的事情

system("pause");

does the same thing

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