O'Reilly logo

C# 5.0 Programmer's Reference by Rod Stephens

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 14 Collection Classes

What’s in This Chapter

  • Arrays and array objects
  • Collection classes
  • Generic collections
  • Collection initialization
  • Iterators

Wrox.com Downloads for This Chapter

Please note that all the code examples for this chapter are available as a part of this chapter’s code download on the book’s website at www.wrox.com/go/csharp5programmersref on the Download Code tab.

Many applications must store and manipulate groups of objects. For example, an application might need to manage a group of Customers, Orders, Students, or Invoices.

An array lets you store a group of objects. Unfortunately, arrays don’t let you easily rearrange the objects. For example, to add an object at the end of an array in C#, you need to create a new array that’s one position bigger than the old array, copy the existing items into the new array, add the new item, and then set the reference to the old array equal to the new one. Adding or removing an item from the beginning or middle of an array is even more time-consuming.

Because these sorts of operations are common, many algorithms have been devised over the years to make them easier. The .NET Framework includes an assortment of collection classes that implement those algorithms, so you don’t have to do it yourself.

This chapter describes collection classes provided by the Framework. It explains how you can use them to store and manipulate groups of objects and provides tips for selecting the right collection for different purposes. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required