Sunday, June 2, 2013

IEnumerable Interface

The IEnumerable interface exposes the enumerator, which supports a simple iteration over a non-generic collection.

Namespace:  System.Collections
ArrayList is a built in class that implements IEnumerable, any class which implements IEnumerable interface should define the GetEnumerator method of the IEnumerable  interface, hence the items in the class can be queried using a foreach loop as follows.

    ArrayList objArrList = new ArrayList();
    foreach (object objItem in objArrList)

This is a generic collection where we do not specify anything about the type of the data which will be handled by the Collection. Notice that the first 3 items in the ArrayList are strings while the last 2 items are integers.

Search Flipkart Products:

No comments: