Chapter 9. Arrays, Indexers, and Collections
The .NET Framework provides a rich suite of collection classes,
The simplest collection is the
Array, the only
collection type for which C# provides built-in support. In this
chapter you will learn to work with single, multidimensional, and
jagged arrays. You will also be introduced to indexers, a bit of C#
syntactic sugar that makes it easier to access class properties, as
though the class were indexed like an array.
The .NET Framework provides a number of interfaces, such as
whose implementation provides you with standard ways to interact with
collections. In this chapter you will see how to work with the most
essential of these. The chapter concludes with a tour of commonly
used .NET collections, including
an indexed collection of objects, all of the same type. C# arrays are
somewhat different from arrays in C++ and other
languages—because they are objects. This provides them with
useful methods and properties.
C# provides native syntax for the declaration of
Array objects. What is actually created, however,
is an object of type
. Arrays in C# thus provide you with the best of both worlds: easy-to-use C-style syntax underpinned with an actual class definition so that instances of an array have access to the methods and properties ...