当所有的EX pressions缺少什么是一个C#的for循环做。例如,用于(;;){} [英] What does a C# for loop do when all the expressions are missing. eg for(;;) {}

查看:132
本文介绍了当所有的EX pressions缺少什么是一个C#的for循环做。例如,用于(;;){}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只能假设这是一个无限循环。

I can only assume it's an infinite loop.

我可以留任何三个EX pressions在for循环?是否有一个默认的每个时省略?

Can I leave out any of the three expressions in a for loop? Is there a default for each when omitted?

推荐答案

这的确是一个无限循环。

It is indeed an infinite loop.

引擎盖下的编译器/抖动将优化这(有效)的简单JMP的操作。

Under the hood the compiler/jitter will optimize this to (effectively) a simple JMP operation.

这也是实际上是相同的:

It's also effectively the same as:

while (true)
{
}

(除了这也是优化掉,因为一段时间前pression的(真)的一部分,通常需要某种形式的比较,但是在这种情况下,没有什么比较。只要继续循环!)

(except that this is also optimized away, since the (true) part of a while expression usually requires some sort of comparison, however in this case, there's nothing to compare. Just keep on looping!)

这篇关于当所有的EX pressions缺少什么是一个C#的for循环做。例如,用于(;;){}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆