Information Technology Reference
In-Depth Information
Useful Inherited Array Members
I mentioned earlier that C# arrays are derived from class System.Array . From that base class,
they inherit a number of useful properties and methods. Some of the most useful ones are
listed in Table 14-1.
Table 14-1. Some Useful Members Inherited by Arrays
Member
Type
Lifetime
Meaning
Rank
Property
Instance
Gets the number of dimensions of the array
Length
Property
Instance
Gets the total number of elements in all the dimensions
of the array
GetLength
Method
Instance
Returns the length of a particular dimension of the array
Clear
Sets a range of elements to 0 or null
Method
Static
Sort
Method
Static
Sorts the elements in a one-dimensional array
BinarySearch
Method
Static
Searches a one-dimensional array for a value, using
binary search
Clone
Method
Instance
Performs a shallow copy of the array—copying only
the elements, both for arrays of value types and refer-
ence types
IndexOf
Method
Static
Returns the index of the first occurrence of a value in a
one-dimensional array
Reverse
Method
Static
Reverses the order of the elements of a range of a one-
dimensional array
GetUpperBound
Method
Instance
Gets the upper bound at the specified dimension
Search WWH ::




Custom Search