to enumerate items request the enumerator ienumerator

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: s IEnumerator IEnumerable and IEnumerator // Construct a type that manages a set of items // This type must offer a public GetEnumerator method SetType st = new SetType(...); // To enumerate items, request the enumerator IEnumerator e = st.GetEnumerator(); // Advance enumerator’s cursor until no more items while (e.MoveNext()) { // Cast the Current item to the proper type ItemType it = (ItemType) e.Current; // Use the item any way you want Console.WriteLine(“Do something with this item: “ + it); } Collection Classes Collections Interfaces ICollection (derived from IEnumerable) Basic collection interface: Count(), CopyTo(), IsSynchronized() IDictionary (derived from ICollection) Basic association container interface Keys / Values table implementation Item indexer looks up a value given its key Add(), Remove(), Contains() and Clear() methods IList (derived from ICollection) A collection whose objects can be individually indexed Item indexer looks up a value given its index Add(), Remove(), Cont...
View Full Document

This note was uploaded on 04/04/2014 for the course CS 5950 taught by Professor Staff during the Summer '08 term at Western Michigan.

Ask a homework question - tutors are online