|
-
Nov 1st, 2006, 08:43 PM
#1
Thread Starter
PowerPoster
IEnumerator
Sorry for all the questions.
I know that collection implement an interface called IEnumerator which returns an IEnumerable object type? Basically, its what is used to store collections and retrieve objects from a collection. It's used in foreach loops and to use them, the class in question must implement the IEnumerator/IEnumerable interface.
I Understand the IEnumerable has 3 methods implemented into your class, Reset, MoveNext and Current?
Now, Everytime I try to read the docs or some source, I get confused as what to actually implement and how it works.
Can someone tell me how to implement the interface into a class so I can enumerate through the collection? What are the guidelines I should follow in order for me to understand/remember what to implement and how the class should look like/act?
So we can have an object of type Person. Person can be people, people would be a collection which holds persons. Using this example, how can I implement and use the IEnumerable interface on the collection, People?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|