的IEnumerator和IEnumerable之间的区别是什么?区别、IEnumerator、IEnumerable

由网友(怪我太多情)分享简介:可能重复: Can谁能解释IEnumerable和IEnumerator的给我吗? 什么是的IEnumerator之间的差异的IEnumerable What are the differences between IEnumerator and IEnumerable?推荐答案的IEnumerable 是定义...

可能重复:   Can谁能解释IEnumerable和IEnumerator的给我吗?

什么是的IEnumerator之间的差异的IEnumerable

What are the differences between IEnumerator and IEnumerable?

推荐答案

的IEnumerable 是定义了一个方法的GetEnumerator 返回一个 IEnumerator接口,这反过来又使只读访问的集合。实现IEnumerable的集合,可以使用一个foreach语句。

IEnumerable is an interface that defines one method GetEnumerator which returns an IEnumerator interface, this in turn allows readonly access to a collection. A collection that implements IEnumerable can be used with a foreach statement.

定义

IEnumerable 

public IEnumerator GetEnumerator();

IEnumerator

public object Current;
public void Reset();
public bool MoveNext();

例如$ C $从codebetter.comÇ

阅读全文

相关推荐

最新文章