Murali Poola
What is the difference between Enumerable and IEnumerator?
By Murali Poola in .NET on Apr 23 2012
  • Murali Poola
    Apr, 2012 23

    IEnumerable is an interface that defines one method GetEnumerator which returns an IEnumeratorinterface, 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();

    The only reason to use IEnumerator is if you have something that has a nonstandard way of enumerating (that is, of returning its various elements one-by-one), and you need to define how that works. You'd create a new class implementing IEnumerator.

    • 1
  • Umar Ali
    Sep, 2012 1

    Please refer to the following URL to know the differences between IEnumerable and IEnumerator,http://onlydifferencefaqs.blogspot.in/2012/07/dotnet-programming-concepts-difference.html

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS