IEnumerator [英] IEnumerator

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

问题描述

我正在从CodeProject中阅读有关IEnumerator的信息,但我无法找出IEnumerator的实际用途.

I was reading about IEnumerator from CodeProject but I was unable to find out what is the actual use of IEnumerator.

推荐答案

它仅用于创建功能就像您班上的foreach.

您会发现 [
It''s just for creating functionality like foreach in your class.

you will find THIS[^] answer convincing.


许多接口和类继承/实现IEnumerable< T>.实现枚举器的接口. IEnumerable声明一个方法

公共IEnumerator GetEnumerator()



IEnumerator支持对集合的简单迭代

参见
http://msdn.microsoft.com/en-us/library/78dfe2yb.aspx [ ^ ]



http://msdn.microsoft.com/en-us/library/s793z9y2.aspx [ ^ ]

问候
Espen Harlinn
Many interfaces and classes inherit/implements the IEnumerable<T> interface to implement enumerators. IEnumerable declares a method

public IEnumerator GetEnumerator()

and

IEnumerator supports a simple iteration over collections

See
http://msdn.microsoft.com/en-us/library/78dfe2yb.aspx[^]

and

http://msdn.microsoft.com/en-us/library/s793z9y2.aspx[^]

Regards
Espen Harlinn


[
This[^] might help you out as well.


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

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