The IEnumerable interface exposes the
enumerator, which supports a simple iteration over a non-generic collection.
Namespace: System.Collections
ArrayList objArrList = new ArrayList();
//
objArrList.Add("Name1");
objArrList.Add("Name2");
objArrList.Add("Name3");
objArrList.Add(5);
objArrList.Add(6);
//
foreach (object
objItem in objArrList)
{
Console.WriteLine(objItem);
}
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.
No comments:
Post a Comment