Author: predmo | Posted on: 2/12/2009 8:21:44 AM | Views : 264

This is probably a silly question but here we go ... . I came across the folowing code and I was hoping someone could explain it to me. I understand that GetEnumerator() returns an IEnumerator Interface but I thought an Interface was a contract for a class to implement certain methods and that it was not actually something that could be instantiated or used to retrieve data itself (since methods are not defined in the Interface) ... anybody able to clarify this?

 

ArrayList coll= new ArrayList();

IEnumerator enumerator =coll.GetEnumerator();

While (enumerator.MoveNext())

{ Console.WriteLine (enumerator.Current);

} 

 
...

Go to the complete details ...