Passing Integer value into GetEnumerator method in ArrayList
In this article I will explain how to pass Pass Integer value into the GetEnumerator(Int32,Int32) method of ArrayList.
The GetEnumerator(Int32,Int32) method of ArrayList returns an enumerator for a range of elements in the ArrayList.Initially, the enumerator is positioned before the first element in the collection,so in order to move the next element we use MoveNext method of enumerator.The first argument of the GetEnumerator method is the index location from where we want to display the element and the second element is the number of element that we want to display.
static void Main(string args)
//create the arraylist named days
ArrayList days = new ArrayList();
//add the elements in the arraylist
//use of GetEnumerator method
//display the elements staring from the index location 2 and print 3 elements onwords.
IEnumerator e2 = days.GetEnumerator(2, 3);
Object obj = e2.Current;
Ask Your Question
Got a programming related question? You may want to post your question here