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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Rights 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
DOI: https://doi.org/10.1007/978-1-4302-3172-1_19
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4302-3171-4
Online ISBN: 978-1-4302-3172-1
eBook Packages: Professional and Applied ComputingApress Access BooksProfessional and Applied Computing (R0)