Chapter 14. Generics and Collections


You saw in Chapter 10 that arrays are useful for when you have a group of objects of the same type, and you need to treat them as a groupas a collection . Arrays are the least flexible of the five standard collections used in C# 2005:

  • Array

  • List

  • Stack

  • Queue

  • Dictionary

This chapter will introduce each of the latter four collections, and will show how the new feature generics are used to make these collections type-safe (and why type-safety is important!).

You can also create classes that act like collections, and you can provide support for your collection classes so that they support some or all of the behavior expected of collections like the ability to be used in a foreach loop or to access their members using an indexer:

 Employee joe = MyCompany[EmployeeID] 



Learning C# 2005
Learning C# 2005: Get Started with C# 2.0 and .NET Programming (2nd Edition)
ISBN: 0596102097
EAN: 2147483647
Year: 2004
Pages: 250

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