Conclusion

Conclusion

Indexers are used to provide array-like access for structures, arrays, and interfaces. Multiple indexers can be provided for a type, and indexers can easily support multiple dimensions. Indexers can be declared as virtual or abstract, and they’re declared with an access protection level, such as public or internal, except when declared as part of an interface.

Enumerators are used to provide a standard navigation mechanism over a set of objects. Types that expose enumerators do so through the IEnumerable interface, which provides a standard way to retrieve an enumerator. All enumerators are derived from the IEnumerator interface, which includes methods for forward-only cursor-style iteration.

In Chapter 8, we’ll expand our examination of indexers and enumerators to look at the various types of collections that are included as part of the .NET Framework class library.



Part III: Programming Windows Forms