Ienumerator的例子是什么? [英] what is Ienumerator with example?

查看:96
本文介绍了Ienumerator的例子是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请给我一个明确的解决方案

please give me a clear solution

推荐答案

尝试这篇CP文章
带有示例的枚举器
try this CP article
Ienumrator with example


IEnumerator是一个接口,在实现时允许您遍历控件列表.要实现它,您需要提供两种方法-重置以返回到列表的开头,移动下一步以向前移动,以及当前以获取当前项目. MSDN在此处提供了一个示例: http://msdn.microsoft.com/en-us/library/system.collections.ienumerator.aspx [ ^ ]
一旦为类实现了IEnumerable,它就可以成为foreach循环的目标.
IEnumerator is an interface, which when implemented allows you to iterate through the list of controls. To implement it requires that you provide two methods - Reset to go back to the beginning of the list, and MoveNext to move forward, and Current to get the current item. MSDN provides an example here: http://msdn.microsoft.com/en-us/library/system.collections.ienumerator.aspx[^]
Once you have implemented IEnumerable for your class, it can become the target of a foreach loop, among other things.


简单来说,Ienumerator是对集合的迭代(非-通用的).它是枚举器的基本接口.但是,枚举器可用于读取集合中的数据,而不能用于修改集合中的数据.因此,您可以自己思考并以身作则,以满足上述基本条件.试试看,让我们知道您是否被卡住.
In simple words Ienumerator is an iteration over a collection (non-generic). It is the base interface for enumerators. However, enumerators can be used to read data in a collection, and it cannot be used to modify the data in the collection. So you can think and example yourself to meet the above basic conditions. Give a try, and let us know if you are stuck.


这篇关于Ienumerator的例子是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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