Summary


With the advent of generics in C# 2.0, the selection of which collection class to use will always favor generics over the nongeneric versions. In fact, C# 2.0 developers should consider the entire namespace of System.Collections as obsolete. In other words, don't go back and necessarily remove all code that already uses this namespace. Instead, use System.Collections.Generics for any new code and, over time, consider migrating existing code to use the corresponding generic collections.

Providing the System.Collections.Generic namespace is not the only change that C# 2.0 brings to collections. Another significant addition is the iterator. Iterators involve a new contextual keyword, yield, that C# uses to trigger underlying CIL code that implements the iterator pattern used by the foreach loop.

The next chapter looks at another C# type, delegates, and their encapsulation into events.




Essential C# 2.0
Essential C# 2.0
ISBN: 0321150775
EAN: 2147483647
Year: 2007
Pages: 185

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net