while(true)和for(;;) [英] while(true) versus for(;;)
本文介绍了while(true)和for(;;)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能的重复项:
是(;;)快(&T); while(TRUE)"如果不是,为什么人们使用它?
for(;;)或while(true) - 这是正确的C#无限循环吗?
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?
while(true)
(或 while(1)
)和 for(;;)
?
推荐答案
启用优化后,它们将以相同的方式编译。
With optimizations enabled, they will compile identically.
您应该使用您认为更易读的那一个。
You should use whichever one you find more readable.
这篇关于while(true)和for(;;)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文