Microsoft® .NET Compact Framework (Core Reference)
by Andy Wigley, Stephen Wheelwright, Robert Burbidge, Rory MacLoed, Mark Sutton
Creating Your Own Collections
The supplied collections will satisfy most application requirements, but if you want to create your own collection class, it’s quite easy to do so. With your own collection classes, you can expose the members as strongly typed items rather than as generic objects, and you can add whatever methods you need to suit the operation of that collection.
You can implement a collection from scratch, and then all you have to do to allow iteration through the collection is implement the IEnumerable interface. This consists of a single method, GetEnumerator, which returns an IEnumerator interface. IEnumerator contains the following methods and properties:
bool MoveNext
This method returns the next item in the list and returns ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access