是什么和foreach的区别 [英] what is the difference between for and foreach
本文介绍了是什么和foreach的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是什么之间的的主要区别
和的foreach
?
在哪些情况下可以,我们使用为
,而不是的foreach
,反之亦然。
In which scenarios can we use for
and not foreach
and vice versa.
有没有可能用一个简单的程序,以显示?
Would it be possible to show with a simple program?
似乎都一样给我。我不能区分它。
Both seem the same to me. I can't differentiate it.
推荐答案
在为
循环是一个构造,说:执行此操作的ñ。次
a for
loop is a construct that says "perform this operation n. times".
在的foreach
循环是一个构造,上面写着
a foreach
loop is a construct that says "perform this operation against each value/object in this IEnumerable"
这篇关于是什么和foreach的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文