Prev | Current Page 197 | Next

Jon Skeet

"C# in Depth: What you need to master C# 2 and 3"

I won??™t be going into the details of ADO.NET, ASP.NET, and the like, but
you??™re bound to use collections in almost any .NET program of any size. This section
will cover the core collections found in the System.Collections.Generic namespace.
We??™ll start in familiar territory with List.
3.5.1 List
We??™ve already seen List several times. Broadly speaking, it??™s the generic equivalent
of the nongeneric ArrayList type, which has been a part of .NET from the word
go. There are some new features, and a few operations in ArrayList didn??™t make it to
List. Most of the features that have been removed from List have also been
removed from other collections, so we??™ll cover them here and then just refer to them
later on when talking about the other collections. Many of the new features in
List (beyond ???being generic???) aren??™t available in the other generic collections.
The combination of these factors leads to our discussion of List being the longest
in this section??”but then it??™s probably the most widely used collection in real-life
code, too. When you think of using a list of data items in your code, List is the
default choice.
I won??™t bore you with the most common operations (adding, removing, fetching,
and replacing items) but will merely point out that List makes itself available in a
large number of situations using old APIs by implementing IList as well as IList.


Pages:
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209