Sunday, April 22, 2012

What is the difference between IEnumerator and IEnumerable?


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.
Definition
 IEnumerable

public IEnumerator GetEnumerator();

IEnumerator

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


No comments:

Post a Comment