System.Array
VB.NET implements arrays with the class System.Array. The Array class has a number of useful methods. Table 9-1 shows a few of the more important methods and properties of the System.Array class.
Table 9-1. Useful methods and properties of System.Array
|
Method or property |
Description |
|---|---|
|
Clear( ) |
Public shared method that sets a range of elements in the array to zero or to a null reference |
|
Copy( ) |
Overloaded public shared method that copies a section of one array to another array |
|
IndexOf( ) |
Overloaded public shared method that returns the index (offset) of the first instance of a value in a one-dimensional array |
|
IsFixedSize |
Public property that returns a value indicating whether the array has a fixed size |
|
LastIndexOf( ) |
Overloaded public shared method that returns the index of the last instance of a value in a one-dimensional array |
|
Length |
Public property that returns the length of the array |
|
Reverse( ) |
Overloaded public shared method that reverses the order of the elements in a one-dimensional array |
|
Rank |
Public property that returns the number of dimensions of the array |
|
Sort( ) |
Overloaded public shared method that sorts the values in a one-dimensional array |
The Array class’s shared methods, Reverse( ) and Sort( ), make manipulation of the objects within the array very easy. Note, however, that to reverse or sort the elements of the array, they must be of a type that implements the IComparable interface, described in Chapter 8. The ...