继续认为有害吗? [英] Continue Considered Harmful?
本文介绍了继续认为有害吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
开发人员应避免在C#中使用继续其他语言强制循环的下一个迭代?支持或反对的论据是否与有关转到的论据重叠?
Should developers avoid using continue in C# or its equivalent in other languages to force the next iteration of a loop? Would arguments for or against overlap with arguments about Goto?
推荐答案
我认为应该更多地使用continue!
I think there should be more use of continue!
我经常遇到如下代码:
for (...)
{
if (!cond1)
{
if (!cond2)
{
... highly indented lines ...
}
}
}
代替
for (...)
{
if (cond1 || cond2)
{
continue;
}
...
}
使用它使代码更具可读性!
Use it to make the code more readable!
这篇关于继续认为有害吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文