Skip to main content
  • 1684 Accesses

Abstract

In this chapter, we took a tour of the generic collection classes, looking at lists, dictionaries, sets, queues, and stacks. These are classes that you will use day-in, day-out in your projects. You’ll probably use List<T> most often to begin with, because it can be used as a direct replacement for an array, which most programmers are already comfortable with. But the other collection classes are worth your attention also, so I suggest you take the time to understand them all.

We also looked at how to apply some collection-like features to arrays using the System.Array class. This is a very useful feature that doesn’t get as much attention as it deserves. Collections are a complement to arrays, not a replacement, and being able to treat an array as you would a collection can be a great time-saver.

Finally, we looked at how to create read-only collections and touched upon the legacy collections that have been part of the .NET class library since before C# supported generics. I strongly recommend that you stick to the generic classes, which have more features and where strong typing will help eliminate runtime exceptions.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

eBook
USD 16.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2010 Adam Freeman

About this chapter

Cite this chapter

Freeman, A. (2010). Collections. In: Introducing Visual C# 2010. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4302-3172-1_19

Download citation

Publish with us

Policies and ethics