
200
LESSON 16 Using ArrAys And ColleCtions
TABLE 161
METHOD PURPOSE
BinarySearch
Uses binary search to find an item in a sorted array.
Clear
Resets a range of items in the array to the default value for the array’s
data type (0, false, or null).
Copy
Copies a range of items from one array to another.
IndexOf
Returns the index of a particular item in the array.
LastIndexOf
Returns the index of the last occurrence of a particular item in the array.
Resize
Resizes the array, preserving any items that fit in the new size.
Reverse
Reverses the order of the items in the array.
Sort
Sorts the array’s items.
COLLECTION CLASSES
An array holds a group of items and lets you refer to them by index. The .NET Framework used by
C# also provides an assortment of collection classes that you can use to store and manipulate items
in other ways. For example, a
Dictionary stores items with keys and lets you very quickly locate an
item from its key. You could use a
Dictionary to make an employee phone book and very quickly
look up a phone number given someone’s name.
Generic Classes
The following sections describe some particular kinds of classes that come pre-built by the .NET
Framework. These are generic classes so before you learn about them you should know a little about
what a generic class is.
A generic class is one that is not tied to a particular data type. For example, suppose you built
a
StringList class that ...