while(true) 与 for(;;)

发布于 2024-09-25 03:20:07 字数 497 浏览 4 评论 0原文

可能的重复:
是“for(;; )”比“while (TRUE)”更快?如果没有,人们为什么要使用它?
for ( ; ; ) 或 while ( true ) - 哪个是正确的 C# 无限循环?

while(true)(或 while(1))和 for( ;;)?有什么理由选择其中之一而不是另一个?

Possible Duplicates:
Is “for(;;)” faster than “while (TRUE)”? If not, why do people use it?
for ( ; ; ) or while ( true ) - Which is the Correct C# Infinite Loop?

Is there any appreciable difference between while(true) (or while(1)) and for(;;)? Would there be any reason to choose one over the other?

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

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

发布评论

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

评论(2

余厌 2024-10-02 03:20:07

启用优化后,它们将进行相同的编译。

您应该使用您认为更具可读性的任何一个。

With optimizations enabled, they will compile identically.

You should use whichever one you find more readable.

与风相奔跑 2024-10-02 03:20:07

不,我认为 for(;;) 看起来更好。但它们是一样的。

另请参阅 是“for( ;;)”比“while (TRUE)”更快?如果没有,人们为什么要使用它?

No. I think for(;;) looks nicer. But they're the same.

Also see Is "for(;;)" faster than "while (TRUE)"? If not, why do people use it?

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