Mono Class Library: System NamespaceSystem.Array Class |
See Also: Array Members
|
All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.
This class is intended to be used as a base class by language implementations that support arrays. Only the system can derive from this type: derived classes of Array are not to be created by the developer.
Note:An array is a collection of identically typed data elements that are accessed and referenced by sets of integral indices.
The rank of an array is the number of dimensions in the array. Each dimension has its own set of indices. An array with a rank greater than one can have a different lower bound and a different number of elements for each dimension. Multidimensional arrays (i.e. arrays with a rank greater than one) are processed in row-major order.
The lower bound of a dimension is the starting index of that dimension.
The length of an array is the total number of elements contained in all of its dimensions.
A vector is a one-dimensional array with a lower bound of '0'.
If the implementer creates a derived class of Array, expected Array behavior cannot be guaranteed. For information on array-like objects with increased functionality, see the IList and IList<T> interfaces. For more information regarding the use of arrays versus the use of collections, see Partition V of the CLI Specification.
Every specific Array type has three instance methods defined on it. While some programming languages allow direct access to these methods, they are primarily intended to be called by the output of compilers based on language syntax that deals with arrays.
- Get: Takes as many int arguments as the array has dimensions and returns the value stored at the given index. It throws a IndexOutOfRangeException exception for invalid indices.
- Set: Takes as many int arguments as the array has dimensions, plus one additional argument (the last argument) which has the same type as an array element. It stores the final value in the specified index of the array. It throws a IndexOutOfRangeException exception for invalid indices.
- Address: Takes as many int arguments as the array has dimensions and returns the address of the element at the given index. It throws a IndexOutOfRangeException exception for invalid indices.
In addition, every specific Array type has a constructor on it that takes as many non-negative int arguments as the array has dimensions. The arguments specify the number of elements in each dimension, and a lower bound of 0. Thus, a two-dimensional array of int objects would have a constructor that could be called with (2, 4) as its arguments to create an array of eight zeros with the first dimension indexed with 0 and 1 and the second dimension indexed with 0, 1, 2, and 3.
For all specific array types except vectors (i.e. those permitted to have non-zero lower bounds and those with more than one dimension) there is an additional constructor. It takes twice as many arguments as the array has dimensions. The arguments are considered in pairs, with the first of the pair specifying the lower bound for that dimension and the second specifying the total number of elements in that dimension. Thus, a two-dimensional array of int objects would also have a constructor that could be called with (-1, 2, 1, 3) as its arguments, specifying an array of 6 zeros, with the first dimension indexed by -1 and 0, and the second dimension indexed by 1, 2, and 3.
Enumeration over an array occurs in ascending row-major order, starting from the first element. (For example, a 2x3 array is traversed in the order [0,0], [0,1], [0,2], [1,0], [1,1], and [1,2].)
Parallel implementation of methods taking a Predicate argument are not permitted.
[Edit]
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0