System.Array Class

public abstract class Array : ICloneable, ICollection, IEnumerable, IList

Base Types

Object
  Array

This type implements ICloneable, IList, ICollection, and IEnumerable.

Assembly

mscorlib

Library

BCL

Summary

Serves as the base class for arrays. Provides methods for creating, copying, manipulating, searching, and sorting arrays.

Description

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 interface. 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.

In addition, every specific Array type has a constructor on it that takes as many positive Int32 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 Int32 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 Int32 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.

See Also

System Namespace

Members

Array Constructors

Array Constructor

Array Methods

Array.BinarySearch(System.Array, System.Object) Method
Array.BinarySearch(System.Array, int, int, System.Object) Method
Array.BinarySearch(System.Array, System.Object, System.Collections.IComparer) Method
Array.BinarySearch(System.Array, int, int, System.Object, System.Collections.IComparer) Method
Array.Clear Method
Array.Clone Method
Array.Copy(System.Array, System.Array, int) Method
Array.Copy(System.Array, int, System.Array, int, int) Method
Array.CopyTo Method
Array.CreateInstance(System.Type, int) Method
Array.CreateInstance(System.Type, int, int) Method
Array.CreateInstance(System.Type, int, int, int) Method
Array.CreateInstance(System.Type, int[]) Method
Array.CreateInstance(System.Type, int[], int[]) Method
Array.GetEnumerator Method
Array.GetLowerBound Method
Array.GetUpperBound Method
Array.GetValue(int[]) Method
Array.GetValue(int) Method
Array.GetValue(int, int) Method
Array.GetValue(int, int, int) Method
Array.IndexOf(System.Array, System.Object) Method
Array.IndexOf(System.Array, System.Object, int) Method
Array.IndexOf(System.Array, System.Object, int, int) Method
Array.Initialize Method
Array.LastIndexOf(System.Array, System.Object) Method
Array.LastIndexOf(System.Array, System.Object, int) Method
Array.LastIndexOf(System.Array, System.Object, int, int) Method
Array.Reverse(System.Array) Method
Array.Reverse(System.Array, int, int) Method
Array.SetValue(System.Object, int) Method
Array.SetValue(System.Object, int, int) Method
Array.SetValue(System.Object, int, int, int) Method
Array.SetValue(System.Object, int[]) Method
Array.Sort(System.Array) Method
Array.Sort(System.Array, System.Array) Method
Array.Sort(System.Array, int, int) Method
Array.Sort(System.Array, System.Array, int, int) Method
Array.Sort(System.Array, System.Collections.IComparer) Method
Array.Sort(System.Array, System.Array, System.Collections.IComparer) Method
Array.Sort(System.Array, int, int, System.Collections.IComparer) Method
Array.Sort(System.Array, System.Array, int, int, System.Collections.IComparer) Method
Array.System.Collections.IList.Add Method
Array.System.Collections.IList.Clear Method
Array.System.Collections.IList.Contains Method
Array.System.Collections.IList.IndexOf Method
Array.System.Collections.IList.Insert Method
Array.System.Collections.IList.Remove Method
Array.System.Collections.IList.RemoveAt Method

Array Properties

Array.IsFixedSize Property
Array.IsReadOnly Property
Array.IsSynchronized Property
Array.Length Property
Array.LongLength Property
Array.Rank Property
Array.SyncRoot Property
Array.System.Collections.ICollection.Count Property
Array.System.Collections.IList.Item Property


Array Constructor

protected Array();

Summary

Constructs a new instance of the Array class.

See Also

System.Array Class, System Namespace

Array.BinarySearch(System.Array, System.Object) Method

public static int BinarySearch(Array array, object value);

Summary

Searches the specified one-dimensional Array for the specified object.

Parameters

array
A Array to search for an object.
value
A Object for which to search, or a null reference. [Note: A null reference will be considered to compare less than any non-null object, or equal to another null reference.]

Return Value

A Int32 with one of the following values based on the result of the search operation.

Return Value Description
The index of value in the array.value was found.
The bitwise complement of the first element that is larger than value.value was not found and the value of at least one element of array was greater than value.
The bitwise complement of (array.GetLowerBound(0) + array.Length).value was not found, and value was greater than the value of all array elements.
[Note: If value is not found, the caller can take the bitwise complement of the return value to determine the index where value would be found in array if it is sorted already.]

Exceptions

Exception TypeCondition
ArgumentExceptionBoth value and at least one element of array do not implement the IComparable interface.

-or-

value is not assignment-compatible with at least one element of array.

-or-

array.UpperBound == System.Int32.MaxValue.

ArgumentNullExceptionarray is null .
RankExceptionarray has more than one dimension.

Description

This version of System.Array.BinarySearch(System.Array,System.Object) is equivalent to System.Array.BinarySearch(System.Array,System.Object)(array, array.GetLowerBound(0), array.Length, value, null ).

value is compared to each element of array using the IComparable interface of the element being compared - or of value if the element being compared does not implement the interface - until an element with a value greater than or equal to value is found. If value does not implement the IComparable interface and is compared to an element that does not implement the IComparable interface, a ArgumentException exception is thrown. If array is not already sorted, correct results are not guaranteed.

[Note: A null reference can be compared with any type; therefore, comparisons with a null reference do not generate exceptions.]

See Also

System.Array Class, System Namespace

Array.BinarySearch(System.Array, int, int, System.Object) Method

public static int BinarySearch(Array array, int index, int length, object value);

Summary

Searches the specified section of the specified one-dimensional Array for the specified value.

Parameters

array
A Array to search.
index
A Int32 that contains the index at which searching starts.
length
A Int32 that contains the number of elements to search, beginning with index .
value
A Object for which to search, or a null reference. [Note: A null reference will be considered to compare less than any non-null object, or equal to another null reference.]

Return Value

A Int32 with one of the following values based on the result of the search operation.

Return ValueDescription
The index of value in the array.value was found.
The bitwise complement of the first element that is larger than value.value was not found, and at least one array element in the range of index to index + length was greater than value.
The bitwise complement of (index + length).value was not found, and value was greater than all array elements in the range of index to index + length.
[Note: If value is not found, the caller can take the bitwise complement of the return value to determine the index of the array where value would be found in the range of index to index + length if array is already sorted.]

Exceptions

Exception TypeCondition
ArgumentNullExceptionarray is null .
RankExceptionarray has more than one dimension.
ArgumentOutOfRangeExceptionindex < array.GetLowerBound(0).

-or-

length < 0.

ArgumentExceptionindex and length do not specify a valid range in array (i.e. index + length > array.GetLowerBound(0) + array.Length).

-or-

Either value or at least one element of array does not implement the IComparable interface.

-or-

value is not assignment-compatible with at least one element of array.

-or-

array.UpperBound == System.Int32.MaxValue.

Description

This version of System.Array.BinarySearch(System.Array,System.Object) is equivalent to System.Array.BinarySearch(System.Array,System.Object)(array, array.GetLowerBound(0), array.Length, value, null ).

value is compared to each element of array using the IComparable interface of the element being compared - or of value if the element being compared does not implement the interface - until an element with a value greater than or equal to value is found. If value does not implement the IComparable interface and is compared to an element that does not implement the IComparable interface, a ArgumentException exception is thrown. If array is not already sorted, correct results are not guaranteed.

[Note: A null reference can be compared with any type; therefore, comparisons with a null reference do not generate exceptions.]

See Also

System.Array Class, System Namespace

Array.BinarySearch(System.Array, System.Object, System.Collections.IComparer) Method

public static int BinarySearch(Array array, object value, IComparer comparer);

Summary

Searches the specified one-dimensional Array for the specified value, using the specified IComparer implementation.

Parameters

array
A Array to search.
value
A Object for which to search, or a null reference. [Note: A null reference will be considered to compare less than any non-null object, or equal to another null reference.]

comparer
The IComparer implementation to use when comparing elements. Specify a null reference to use the IComparable implementation of each element.

Return Value

A Int32 with one of the following values based on the result of the search operation.

Return ValueDescription
The index of value in the array.value was found.
The bitwise complement of the first element that is larger than value.value was not found, and at least one array element was greater than value.
The bitwise complement of (array.GetLowerBound(0) + array.Length).value was not found, and value was greater than all array elements.
[Note: If value is not found, the caller can take the bitwise complement of the return value to determine the index where value would be found in array if it is already sorted.]

Exceptions

Exception TypeCondition
ArgumentExceptioncomparer is null , and both value and at least one element of array do not implement the IComparable interface.

-or-

comparer is null , and value is not assignment-compatible with at least one element of array.

-or-

array.UpperBound == System.Int32.MaxValue.

ArgumentNullExceptionarray is null .
RankExceptionarray has more than one dimension.

Description

This version of System.Array.BinarySearch(System.Array,System.Object) is equivalent to System.Array.BinarySearch(System.Array,System.Object)(array, array.GetLowerBound(0), array.Length, value, comparer).

value is compared to each element of array using comparer until an element with a value greater than or equal to value is found. If comparer is null , the IComparable interface of the element being compared - or of value if the element being compared does not implement the interface - is used. If value does not implement the IComparable interface and is compared to an element that does not implement the IComparable interface, a ArgumentException exception is thrown. If array is not already sorted, correct results are not guaranteed.

[Note: A null reference can be compared with any type; therefore, comparisons with a null reference do not generate exceptions.]

See Also

System.Array Class, System Namespace

Array.BinarySearch(System.Array, int, int, System.Object, System.Collections.IComparer) Method

public static int BinarySearch(Array array, int index, int length, object value, IComparer comparer);

Summary

Searches the specified section of the specified one-dimensional Array for the specified value, using the specified IComparer implementation.

Parameters

array
A Array to search.
index
A Int32 that contains the index at which searching starts.
length
A Int32 that contains the number of elements to search, beginning with index .
value
A Object for which to search, or a null reference. [Note: A null reference will be considered to compare less than any non-null object, or equal to another null reference.]

comparer
The IComparer implementation to use when comparing elements. Specify a null reference to use the IComparable implementation of each element.

Return Value

A Int32 with one of the following values based on the result of the search operation.

Return ValueDescription
The index of value in the array.value was found.
The bitwise complement of the first element that is larger than value.value was not found, and at least one array element in the range of index to index + length was greater than value.
The bitwise complement of (index + length).value was not found, and value was greater than all array elements in the range of index to index + length.
[Note: If value is not found, the caller can take the bitwise complement of the return value to determine the index of array where value would be found in the range of index to index + length if array is already sorted.]

Exceptions

Exception TypeCondition
ArgumentNullExceptionarray is null .
RankExceptionarray has more than one dimension.
ArgumentOutOfRangeExceptionindex < array.GetLowerBound(0).

-or-

length < 0.

ArgumentExceptionindex and length do not specify a valid range in array (i.e. index + length > array.GetLowerBound(0) + array.Length).

-or-

comparer is null , and both value and at least one element of array do not implement the IComparable interface.

-or-

comparer is null , and value is not of the same type as the elements of array.

-or-

array.UpperBound == System.Int32.MaxValue.

Description

value is compared to each element of array using comparer until an element with a value greater than or equal to value is found. If comparer is null , the IComparable interface of the element being compared - or of value if the element being compared does not implement the interface -- is used. If value does not implement the IComparable interface and is compared to an element that does not implement the IComparable interface, a ArgumentException exception is thrown. If array is not already sorted, correct results are not guaranteed.

[Note: A null reference can be compared with any type; therefore, comparisons with a null reference do not generate exceptions.]

Example

This example demonstrates the System.Array.BinarySearch(System.Array,System.Object) method.

using System;
class BinarySearchExample {
  public static void Main() {    
    int[] intAry = { 0, 2, 4, 6, 8 };
    Console.WriteLine( "The indices and elements of the array are: ");
    for ( int i = 0; i < intAry.Length; i++ )
      Console.Write("[{0}]: {1, -5}", i, intAry[i]);
    Console.WriteLine();
    SearchFor( intAry, 3 );
    SearchFor( intAry, 6 );
    SearchFor( intAry, 9 );
  }
  public static void SearchFor( Array ar, Object value ) {
    int i = Array.BinarySearch( ar, 0, ar.Length, value, null );
    Console.WriteLine();
    if ( i > 0 ) {
      Console.Write( "The object searched for, {0}, was found ", value );
      Console.WriteLine( "at index {1}.", value, i );
    }
    else if ( ~i == ar.Length ) {
      Console.Write( "The object searched for, {0}, was ", value );
      Console.Write( "not found,\nand no object in the array had " );
      Console.WriteLine( "greater value. " );
    }
    else {
      Console.Write( "The object searched for, {0}, was ", value );
      Console.Write( "not found.\nThe next larger object is at " );
      Console.WriteLine( "index {0}.", ~i );
    }
  }
}
   
The output is

The indices and elements of the array are:

[0]:0 [1]:2 [2]:4 [3]:6 [4]:8

The object searched for, 3, was not found.

The next larger object is at index 2.

The object searched for, 6, was found at index 3.

The object searched for, 9, was not found,

and no object in the array had greater value.

See Also

System.Array Class, System Namespace

Array.Clear Method

public static void Clear(Array array, int index, int length);

Summary

Sets the specified range of elements in the specified Array to zero, false, or to a null reference, depending on the element type.

Parameters

array
The Array to clear.
index
A Int32 that contains the index at which clearing starts.
length
A Int32 that contains the number of elements to clear, beginning with index.

Exceptions

Exception TypeCondition
ArgumentNullExceptionarray is null .
ArgumentOutOfRangeExceptionindex < array.GetLowerBound(0).

length < 0.

index and length do not specify a valid range in array (i.e. index + length > array.GetLowerBound(0) + array.Length ).

Description

Reference-type elements will be set to null . Value-type elements will be set to zero, except for Boolean elements, which will be set to false .

See Also

System.Array Class, System Namespace

Array.Clone Method

public virtual object Clone();

Summary

Returns a Object that is a copy of the current instance.

Return Value

A Object that is a copy of the current instance.

Description

[Note: This method is implemented to support the ICloneable interface.]

[Behaviors: Each of the elements of the current instance is copied to the clone. If the elements are reference types, the references are copied. If the elements are value-types, the values are copied. The clone is of the same type as the current instance.]

[Default: As described above.]

[Overrides: Override this method to return a clone of an array.]

[Usage: Use this method to obtain the clone of an array.]

Example

This example demonstrates the System.Array.Clone method.

using System;
public class ArrayCloneExample {
  public static void Main() {
    int[] intAryOrig = { 3, 4, 5 };
    //must explicitly convert clones object into an array
    int[] intAryClone = (int[]) intAryOrig.Clone();
    Console.Write( "The elements of the first  array are: " );
    foreach( int i in intAryOrig )
      Console.Write( "{0,3}", i );
    Console.WriteLine();
    Console.Write( "The elements of the cloned array are: " );
    foreach( int i in intAryClone )
      Console.Write( "{0,3}", i );
    Console.WriteLine();
    //Clear the values of the original array.
    Array.Clear( intAryOrig, 0, 3 );
    Console.WriteLine( "After clearing the first array," );
    Console.Write( "The elements of the first  array are: " );
    foreach( int i in intAryOrig )
      Console.Write( "{0,3}", i );
    Console.WriteLine();
    Console.Write( "The elements of the cloned array are: " );
    foreach( int i in intAryClone )
      Console.Write( "{0,3}", i );
  }
}
   
The output is

The elements of the first array are: 3 4 5

The elements of the cloned array are: 3 4 5

After clearing the first array,

The elements of the first array are: 0 0 0

The elements of the cloned array are: 3 4 5

See Also

System.Array Class, System Namespace

Array.Copy(System.Array, System.Array, int) Method

public static void Copy(Array sourceArray, Array destinationArray, int length);

Summary

Copies the specified number of elements from the specified source array to the specified destination array.

Parameters

sourceArray
A Array that contains the data to copy.
destinationArray
A Array that receives the data.
length
A Int32 designating the number of elements to copy, starting with the first element and proceeding in order.

Exceptions

Exception TypeCondition
ArgumentNullExceptionsourceArray or destinationArray is null .

RankExceptionsourceArray and destinationArray have different ranks.

ArrayTypeMismatchExceptionThe elements in both arrays are built-in types, and converting from the type of the elements of sourceArray into the type of the elements in destinationArray requires a narrowing conversion.

-or-

Both arrays are built-in types, and one array is a value-type array and the other an array of interface type not implemented by that value-type.

-or-

Both arrays are user-defined value types and are not of the same type.

InvalidCastException At least one of the elements in sourceArray is not assignment-compatible with the type of destinationArray.

ArgumentOutOfRangeExceptionlength < 0.

ArgumentExceptionlength < sourceArray.Length.

-or-

length < destinationArray.Length.

Description

This version of System.Array.Copy(System.Array,System.Array,System.Int32) is equivalent to System.Array.Copy(System.Array,System.Array,System.Int32) (sourceArray, sourceArray.GetLowerBound(0), destinationArray, destinationArray.GetLowerBound(0), length).

If sourceArray and destinationArray are of different types, System.Array.Copy(System.Array,System.Array,System.Int32) performs widening conversions on the elements of sourceArray as necessary before storing the information in destinationArray. Value types will be boxed when being converted to a Object. If the necessary conversion is a narrowing conversion, a ArrayTypeMismatchException exception is thrown. [Note: For information regarding valid conversions performed by this method, see Convert.]

If an exception is thrown while copying, the state of destinationArray is undefined.

If sourceArray and destinationArray are the same array, System.Array.Copy(System.Array,System.Array,System.Int32) copies the source elements safely to their destination, as if the copy were done through an intermediate array.

Example

This example demonstrates the System.Array.Copy(System.Array,System.Array,System.Int32) method.

using System;
public class ArrayCopyExample {
   public static void Main() {
      int[] intAryOrig = new int[3];
      double[] dAryCopy = new double[3];
      for ( int i = 0; i < intAryOrig.Length; i++ )
         intAryOrig[i] = i+3;
      //copy the first 2 elements of the source into the destination
      Array.Copy( intAryOrig, dAryCopy, 2);
      Console.Write( "The elements of the first array are: " );
      for ( int i = 0; i < intAryOrig.Length; i++ ) 
         Console.Write( "{0,3}", intAryOrig[i] );
      Console.WriteLine();
      Console.Write( "The elements of the copied array are: " );
      for ( int i = 0; i < dAryCopy.Length; i++ ) 
         Console.Write( "{0,3}", dAryCopy[i] );
   }
}
   
The output is

The elements of the first array are: 3 4 5

The elements of the copied array are: 3 4 0

See Also

System.Array Class, System Namespace

Array.Copy(System.Array, int, System.Array, int, int) Method

public static void Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length);

Summary

Copies the specified number of elements from a source array starting at the specified source index to a destination array starting at the specified destination index.

Parameters

sourceArray
The Array that contains the data to copy.
sourceIndex
A Int32 that contains the index in sourceArray from which copying begins.
destinationArray
The Array that receives the data.
destinationIndex
A Int32 that contains the index in destinationArray at which storing begins.
length
A Int32 that contains the number of elements to copy.

Exceptions

Exception TypeCondition
ArgumentNullExceptionsourceArray or destinationArray is null .

RankExceptionsourceArray and destinationArray have different ranks.

ArrayTypeMismatchExceptionThe elements in both arrays are built-in types, and converting from the type of the elements of sourceArray into the type of the elements in destinationArray requires a narrowing conversion.

-or-

Both arrays are built-in types, and one array is a value-type array and the other an array of interface type not implemented by that value-type.

-or-

Both arrays are user-defined value types and are not of the same type.

InvalidCastExceptionAt least one element in sourceArray is assignment-incompatible with the type of destinationArray.

ArgumentOutOfRangeExceptionsourceIndex < sourceArray.GetLowerBound(0).

-or-

destinationIndex < destinationArray.GetLowerBound(0).

-or-

length < 0.

ArgumentException(sourceIndex + length ) > (sourceArray.GetLowerBound(0) + sourceArray.Length).

(destinationIndex + length ) > ( destinationArray.GetLowerBound(0) + destinationArray.Length).

Description

If sourceArray and destinationArray are of different types, System.Array.Copy(System.Array,System.Array,System.Int32) performs widening conversions on the elements of sourceArray as necessary before storing the information in destinationArray. Value types will be boxed when being converted to a Object. If the necessary conversion is a narrowing conversion, a ArrayTypeMismatchException exception is thrown. [Note: For information regarding valid conversions performed by this method, see Convert .]

If an exception is thrown while copying, the state of destinationArray is undefined.

If sourceArray and destinationArray are the same array, System.Array.Copy(System.Array,System.Array,System.Int32) copies the source elements safely to their destination as if the copy were done through an intermediate array.

Example

This example demonstrates the System.Array.Copy(System.Array,System.Array,System.Int32) method.

using System;
class ArrayCopyExample {
   public static void Main() {
      int[] intAry = { 0, 10, 20, 30, 40, 50 };
      Console.Write( "The elements of the array are: " );
      foreach ( int i in intAry )
         Console.Write( "{0,3}", i );
      Console.WriteLine();
      Array.Copy( intAry, 2, intAry, 0, 4 );
      Console.WriteLine( "After copying elements 2 through 5 into elements 0 through 4" );
      Console.Write( "The elements of the array are: " );
      foreach ( int i in intAry )
         Console.Write( "{0,3}", i );
      Console.WriteLine();     
   }
}
   
The output is

The elements of the array are: 0 10 20 30 40 50

After copying elements 2 through 5 into elements 0 through 4

The elements of the array are: 20 30 40 50 40 50

See Also

System.Array Class, System Namespace

Array.CopyTo Method

public virtual void CopyTo(Array array, int index);

Summary

Copies all the elements of the current instance to the specified one-dimensional array starting at the specified relative index in the destination array.

Parameters

array
A one-dimensional Array that is the destination of the elements copied from the current instance.
index
A Int32 that contains the relative zero-based index in array at which copying begins.

Exceptions

Exception TypeCondition
ArgumentNullExceptionarray is null .
RankExceptionThe current instance has more than one dimension.

ArgumentOutOfRangeExceptionindex < 0.
ArgumentExceptionarray has more than one dimension.

-or-

index is greater than or equal to array.Length.

-or-

The number of elements in the current instance is greater than the available space from index to the end of array.

ArrayTypeMismatchExceptionThe type of the current instance cannot be cast automatically to the type of array.

Description

[Note: This method is implemented to support the ICollection interface. If implementing ICollection is not explicitly required, use System.Array.Copy(System.Array,System.Array,System.Int32) to avoid an extra indirection.

index is a relative index, not the actual array index. If the index of array is zero-based, this value is the same as the actual index at which copying begins. If the lower bound of array is not zero, the value of index is added to the lower bound of array to get the actual index at which copying begins. For example, if the lower bound of array is 2 and the value of index is 1, the copying actually starts at index 3.

If this method throws an exception while copying, the state of array is undefined.

]

[Behaviors: As described above.]

[Default: As described above.]

[Overrides: Override this method to copy elements of the current instance to a specified array.]

[Usage: Use this method to copy elements of the current instance to a specified array.]

Example

The following example shows how to copy the elements of one Array into another.

using System;

public class ArrayCopyToExample
{
   public static void Main()
   {
      Array aryOne = Array.CreateInstance(typeof(Object), 3);
      aryOne.SetValue("one", 0);
      aryOne.SetValue("two", 1);
      aryOne.SetValue("three", 2);

      Array aryTwo = Array.CreateInstance(typeof(Object), 5);
      for (int i=0; i < aryTwo.Length; i++)
         aryTwo.SetValue(i, i);

      Console.WriteLine("The contents of the first array are:");
      foreach (object o in aryOne)
         Console.Write("{0} ", o);
      Console.WriteLine();
      Console.WriteLine("The original contents of the second array are:");
      foreach (object o in aryTwo)
         Console.Write("{0} ", o);
      Console.WriteLine();
      
      aryOne.CopyTo(aryTwo, 1);

      Console.WriteLine("The new contents of the second array are:");
      foreach( object o in aryTwo)
         Console.Write("{0} ", o);
   }
}
The output is

The contents of the first array are:

one two three

The original contents of the second array are:

0 1 2 3 4

The new contents of the second array are:

0 one two three 4

See Also

System.Array Class, System Namespace

Array.CreateInstance(System.Type, int) Method

public static Array CreateInstance(Type elementType, int length);

Summary

Constructs a zero-based, one-dimensional array with the specified number of elements of the specified type.

Parameters

elementType
The Type of the elements contained in the new Array instance.
length
A Int32 that contains the number of elements contained in the new Array instance.

Return Value

A zero-based, one-dimensional Array object containing length elements of type elementType.

Exceptions

Exception TypeCondition
ArgumentNullExceptionelementType is null .
ArgumentExceptionelementType is not a valid Type.
ArgumentOutOfRangeExceptionlength < 0.

Description

Reference-type elements will be set to null . Value-type elements will be set to zero, except for Boolean elements, which will be set to false .

[Note: Unlike most classes, Array provides the System.Array.CreateInstance(System.Type,System.Int32) method, instead of public constructors, to allow for late bound access.]

Example

The following example shows how to create and initialize a one-dimensional Array.

using System;

public class ArrayCreateInstanceExample
{

   public static void Main()
   {

      Array intAry = Array.CreateInstance(typeof(int),5);
      for (int i=intAry.GetLowerBound(0);i<=intAry.GetUpperBound(0);i++)
         intAry.SetValue(i*3,i);
      Console.Write("The values of the array are:");
      foreach (int i in intAry)
         Console.Write("{0} ",i);
   
   }

}
   
The output is

The values of the array are: 0 3 6 9 12

See Also

System.Array Class, System Namespace

Array.CreateInstance(System.Type, int, int) Method

public static Array CreateInstance(Type elementType, int length1, int length2);

Summary

Creates a zero-based, two-dimensional array of the specified Type and dimension lengths.

Parameters

elementType
The Type of the elements contained in the new Array instance.
length1
A Int32 that contains the number of elements contained in the first dimension of the new Array instance.
length2
A Int32 that contains the number of elements contained in the second dimension of the new Array instance.

Return Value

A new zero-indexed, two-dimensional Array instance of elementType objects with the size length1 for the first dimension and length2 for the second.

Exceptions

Exception TypeCondition
ArgumentNullExceptionelementType is null .
ArgumentExceptionelementType is not a valid Type.
ArgumentOutOfRangeExceptionlength1 < 0.

-or-

length2 < 0.

Description

Reference-type elements will be set to null . Value-type elements will be set to zero, except for Boolean elements, which will be set to false .

[Note: Unlike most classes, Array provides the System.Array.CreateInstance(System.Type,System.Int32) method, instead of public constructors, to allow for late bound access.]

Example

The following example shows how to create and initialize a two-dimensional Array.

using System;

public class Create2DArrayExample
{
   public static void Main()
   {
      int i, j;
      Array ary = Array.CreateInstance( typeof(int), 5, 3 );
      for( i = ary.GetLowerBound(0); i <= ary.GetUpperBound(0); i++ )
      {
         for( j = ary.GetLowerBound(1); j <= ary.GetUpperBound(1); j++ )
         {
            ary.SetValue( (10*i + j), i, j );
         }
      }
      Console.WriteLine("The elements of the array are:");
      for( i = ary.GetLowerBound(0); i <= ary.GetUpperBound(0); i++)
      {
         for( j = ary.GetLowerBound(1); j <= ary.GetUpperBound(1); j++)
         {
            Console.Write("{0, 2} ", ary.GetValue(i, j));
         }
         Console.WriteLine();
      }
   }
} 
  
The output is

The elements of the array are:
 0  1  2
10 11 12
20 21 22
30 31 32
40 41 42
 

Library

ExtendedArray

See Also

System.Array Class, System Namespace

Array.CreateInstance(System.Type, int, int, int) Method

public static Array CreateInstance(Type elementType, int length1, int length2, int length3);

Summary

Creates a zero-based, three-dimensional array of the specified Type and dimension lengths.

Parameters

elementType
The Type of the elements contained in the new Array instance.
length1
A Int32 that contains the number of elements contained in the first dimension of the new Array instance.
length2
A Int32 that contains the number of elements contained in the second dimension of the new Array instance.
length3
A Int32 that contains the number of elements contained in the third dimension of the new Array instance.

Return Value

A new zero-based, three-dimensional Array instance of elementType objects with the size length1 for the first dimension, length2 for the second, and length3 for the third.

Exceptions

Exception TypeCondition
ArgumentNullExceptionelementType is null .
ArgumentExceptionelementType is not a valid Type.
ArgumentOutOfRangeExceptionlength1 < 0.

-or-

length2 < 0.

-or-

length3 < 0.

Description

Reference-type elements will be set to null . Value-type elements will be set to zero, except for Boolean elements, which will be set to false .

[Note: Unlike most classes, Array provides the System.Array.CreateInstance(System.Type,System.Int32) method, instead of public constructors, to allow for late bound access.]

Example

The following example shows how to create and initialize a three-dimensional Array.

using System;

public class Create3DArrayExample
{
   public static void Main()
   {
      int i, j, k;
      Array ary = Array.CreateInstance( typeof(int), 2, 4, 3 );
      for( i = ary.GetLowerBound(0); i <= ary.GetUpperBound(0); i++ )
      {
         for( j = ary.GetLowerBound(1); j <= ary.GetUpperBound(1); j++ )
         {
            for( k = ary.GetLowerBound(2); k <= ary.GetUpperBound(2); k++ )
            {
               ary.SetValue( (100*i + 10*j + k), i, j, k );
            }
         }
      }
      Console.WriteLine("The elements of the array are:");
      for( i = ary.GetLowerBound(0); i <= ary.GetUpperBound(0); i++)
      {
         for( j = ary.GetLowerBound(1); j <= ary.GetUpperBound(1); j++)
         {
             for( k = ary.GetLowerBound(2); k <= ary.GetUpperBound(2); k++ )
            {
               Console.Write("{0, 3} ", ary.GetValue(i, j, k));
            }
            Console.WriteLine();
         }
         Console.WriteLine();
      }
   }
}
   
The output is

The elements of the array are:
  0   1   2
 10  11  12
 20  21  22
 30  31  32

100 101 102
110 111 112
120 121 122
130 131 132
 

Library

ExtendedArray

See Also

System.Array Class, System Namespace

Array.CreateInstance(System.Type, int[]) Method

public static Array CreateInstance(Type elementType, int[] lengths);

Summary

Creates a zero-based, multidimensional array of the specified Type and dimension lengths.

Parameters

elementType
The Type of the elements contained in the new Array instance.
lengths
A one-dimensional array of Int32 objects that contains the size of each dimension of the new Array instance.

Return Value

A new zero-based, multidimensional Array instance of the specified Type with the specified length for each dimension. The System.Array.Rank of the new instance is equal to lengths.Length.

Exceptions

Exception TypeCondition
ArgumentNullExceptionelementType orlengths is null .

ArgumentExceptionelementType is not a valid Type.

-or-

lengths.Length = 0.

ArgumentOutOfRangeExceptionA value in lengths is less than zero.

Description

The number of elements in lengths is required to equal the number of dimensions in the new Array instance. Each element of lengths specifies the length of the corresponding dimension in the new instance.

Reference-type elements will be set to null . Value-type elements will be set to zero, except for Boolean elements, which will be set to false .

[Note: Unlike most classes, Array provides the System.Array.CreateInstance(System.Type,System.Int32) method, instead of public constructors, to allow for late bound access.]

Example

The following example shows how to create and initialize a multidimensional Array.

using System;

public class CreateMultiDimArrayExample
{
   public static void Main()
   {
      int i, j, k;
      int[] indexAry = {2, 4, 5};
      Array ary = Array.CreateInstance( typeof(int), indexAry );
      for( i = ary.GetLowerBound(0); i <= ary.GetUpperBound(0); i++ )
      {
         for( j = ary.GetLowerBound(1); j <= ary.GetUpperBound(1); j++ )
         {
            for( k = ary.GetLowerBound(2); k <= ary.GetUpperBound(2); k++ )
            {
               ary.SetValue( (100*i + 10*j + k), i, j, k );
            }
         }
      }
      Console.WriteLine("The elements of the array are:");
      for( i = ary.GetLowerBound(0); i <= ary.GetUpperBound(0); i++)
      {
         for( j = ary.GetLowerBound(1); j <= ary.GetUpperBound(1); j++)
         {
             for( k = ary.GetLowerBound(2); k <= ary.GetUpperBound(2); k++ )
            {
               Console.Write("{0, 3} ", ary.GetValue(i, j, k));
            }
            Console.WriteLine();
         }
         Console.WriteLine();
      }
   }
}
   
The output is

The elements of the array are:
  0   1   2   3   4
 10  11  12  13  14
 20  21  22  23  24
 30  31  32  33  34

100 101 102 103 104
110 111 112 113 114
120 121 122 123 124
130 131 132 133 134 

Library

ExtendedArray

See Also

System.Array Class, System Namespace

Array.CreateInstance(System.Type, int[], int[]) Method

public static Array CreateInstance(Type elementType, int[] lengths, int[] lowerBounds);

Summary

Creates a multidimensional array of the specified Type and dimension lengths, with the specified lower bounds.

Parameters

elementType
The Type of the elements contained in the new Array instance.
lengths
A one-dimensional array of Int32 objects that contains the size of each dimension of the new Array instance.
lowerBounds
A one-dimensional array of Int32 objects that contains the lower bound of each dimension of the new Array instance.

Return Value

A new multidimensional Array of the specified Type with the specified length and lower bound for each dimension.

Exceptions

Exception TypeCondition
ArgumentNullExceptionelementType, lengths, or lowerBounds is null .

ArgumentExceptionelementType is not a valid Type.

-or-

lengths.Length = 0.

-or-

lengths and lowerBounds do not contain the same number of elements.

ArgumentOutOfRangeExceptionA value in lengths is less than zero.

Description

The lengths and lowerBounds are required to have the same number of elements. The number of elements in lengths equals the number of dimensions in the new Array instance

Each element of lengths specifies the length of the corresponding dimension in the new Array instance.

Each element of lowerBounds specifies the lower bound of the corresponding dimension in the new Array instance.

Reference-type elements will be set to null . Value-type elements will be set to zero, except for Boolean elements, which will be set to false .

[Note: Unlike most classes, Array provides the System.Array.CreateInstance(System.Type,System.Int32) method, instead of public constructors, to allow for late bound access.]

Example

The following example shows how to create and initialize a multidimensional Array with specified low bounds.

using System;

public class MultiDimNonZeroBoundExample
{
   public static void Main()
   {
      int i, j, k;
      int[] indexAry = {4, 2, 3};
      int[] lowboundAry = {3, 2, 1};
      Array ary = Array.CreateInstance( typeof(int), indexAry, lowboundAry );
      for( i = ary.GetLowerBound(0); i <= ary.GetUpperBound(0); i++ )
      {
         for( j = ary.GetLowerBound(1); j <= ary.GetUpperBound(1); j++ )
         {
            for( k = ary.GetLowerBound(2); k <= ary.GetUpperBound(2); k++ )
            {
               ary.SetValue( (100*i + 10*j + k), i, j, k );
            }
         }
      }
      Console.WriteLine("The elements of the array are:");
      for( i = ary.GetLowerBound(0); i <= ary.GetUpperBound(0); i++)
      {
         for( j = ary.GetLowerBound(1); j <= ary.GetUpperBound(1); j++)
         {
             for( k = ary.GetLowerBound(2); k <= ary.GetUpperBound(2); k++ )
            {
               Console.Write("{0, 3} ", ary.GetValue(i, j, k));
            }
            Console.WriteLine();
         }
         Console.WriteLine();
      }
   }
}
   
The output is

The elements of the array are:
321 322 323
331 332 333

421 422 423
431 432 433

521 522 523
531 532 533

621 622 623
631 632 633

Library

ExtendedArray

See Also

System.Array Class, System Namespace

Array.GetEnumerator Method

public virtual IEnumerator GetEnumerator();

Summary

Returns a IEnumerator for the current instance.

Return Value

A IEnumerator for the current instance.

Description

A IEnumerator grants read-access to the elements of a Array.

[Note: This method is implemented to support the IEnumerator interface. For more information regarding the use of an enumerator, see IEnumerator.]

[Behaviors: Initially, the enumerator is positioned before the first element of the current instance. System.Collections.IEnumerator.Reset returns the enumerator to this position. Therefore, after an enumerator is created or after a System.Collections.IEnumerator.Reset, System.Collections.IEnumerator.MoveNext is required to be called to advance the enumerator to the first element of the collection before reading the value of System.Collections.IEnumerator.Current.

The enumerator is in an invalid state if it is positioned before the first element or after the last element of the current instance. Whenever the enumerator is in an invalid state, a call to System.Collections.IEnumerator.Current is required to throw a InvalidOperationException.

System.Collections.IEnumerator.Current returns the same object until either System.Collections.IEnumerator.MoveNext or System.Collections.IEnumerator.Reset is called.

Once the enumerator of the current instance is moved immediately past the last element of the current instance, subsequent calls to System.Collections.IEnumerator.MoveNext return false and the enumerator remains positioned immediately past the last element.

]

[Default: Multidimensional arrays will be processed in Row-major form.

[Note: For some multidimensional Array objects, it may be desirable for an enumerator to process them in Column-major form.]

]

[Overrides: Override this method to provide read-access to the current instance.]

[Usage: Use this method to iterate over the elements of the current instance.]

Example

This example demonstrates the System.Array.GetEnumerator method.

using System;
using System.Collections;
public class ArrayGetEnumerator {
   public static void Main() {
      string[,] strAry = {{"1","one"}, {"2", "two"}, {"3", "three"}};
      Console.Write( "The elements of the array are: " );
      IEnumerator sEnum = strAry.GetEnumerator();
      while ( sEnum.MoveNext() )
         Console.Write( " {0}", sEnum.Current );
   }
}
   
The output is

The elements of the array are: 1 one 2 two 3 three

See Also

System.Array Class, System Namespace

Array.GetLowerBound Method

public int GetLowerBound(int dimension);

Summary

Returns the lower bound of the specified dimension in the current instance.

Parameters

dimension
A Int32 that contains the zero-based dimension of the current instance whose lower bound is to be determined.

Return Value

A Int32 that contains the lower bound of the specified dimension in the current instance.

Exceptions

Exception TypeCondition
IndexOutOfRangeExceptiondimension < 0.

-or-

dimension is equal to or greater than the System.Array.Rank property of the current instance.

Description

[Note: For example, System.Array.GetLowerBound(System.Int32) (0) returns the lower bound of the first dimension of the current instance, and System.Array.GetLowerBound(System.Int32)(System.Array.Rank - 1) returns the lower bound of the last dimension of the current instance.]

Library

RuntimeInfrastructure

See Also

System.Array Class, System Namespace

Array.GetUpperBound Method

public int GetUpperBound(int dimension);

Summary

Returns the upper bound of the specified dimension in the current instance.

Parameters

dimension
A Int32 that contains the zero-based dimension of the current instance whose upper bound is to be determined.

Return Value

A Int32 that contains the upper bound of the specified dimension in the current instance.

Exceptions

Exception TypeCondition
IndexOutOfRangeExceptiondimension < 0.

-or-

dimension is equal to or greater than the System.Array.Rank property of the current instance.

Description

[Note: For example, System.Array.GetUpperBound(System.Int32) (0) returns the upper bound of the first dimension of the current instance, and System.Array.GetUpperBound(System.Int32)(System.Array.Rank - 1) returns the upper bound of the last dimension of the current instance.]

Library

RuntimeInfrastructure

See Also

System.Array Class, System Namespace

Array.GetValue(int[]) Method

public object GetValue(int[] indices);

Summary

Gets the value at the specified position in the current multidimensional instance.

Parameters

indices
A one-dimensional array of Int32 objects that contains the indices that specify the position of the element in the current instance whose value to get.

Return Value

A Object that contains the value at the specified position in the current instance.

Exceptions

Exception TypeCondition
ArgumentNullExceptionindices is null .
ArgumentExceptionThe number of dimensions in the current instance is not equal to the number of elements in indices.
IndexOutOfRangeExceptionAt least one element in indices is outside the range of valid indices for the corresponding dimension of the current instance.

Description

The number of elements in indices is required to be equal to the number of dimensions in the current instance. All elements in indices collectively specify the position of the desired element in the current instance.

[Note: Use the System.Array.GetLowerBound(System.Int32) and System.Array.GetUpperBound(System.Int32) methods to determine whether any of the values in indices are out of bounds.]

Library

ExtendedArray

See Also

System.Array Class, System Namespace

Array.GetValue(int) Method

public object GetValue(int index);

Summary

Gets the value at the specified position in the current one-dimensional instance.

Parameters

index
A Int32 that contains the position of the value to get from the current instance.

Return Value

A Object that contains the value at the specified position in the current instance.

Exceptions

Exception TypeCondition
ArgumentExceptionThe current instance has more than one dimension.
IndexOutOfRangeExceptionindex is outside the range of valid indices for the current instance.

Description

[Note: Use the System.Array.GetLowerBound(System.Int32) and System.Array.GetUpperBound(System.Int32) methods to determine whether index is out of bounds.]

Example

This example demonstrates the System.Array.GetValue(System.Int32[]) method.

using System;
public class ArrayGetValueExample {
   public static void Main() {
      String[] strAry = { "one", "two", "three", "four", "five" };
      Console.Write( "The elements of the array are: " );
      for( int i = 0; i < strAry.Length; i++ )
         Console.Write( " '{0}' ", strAry.GetValue( i ) );
   }
}
   
The output is

The elements of the array are: 'one' 'two' 'three' 'four' 'five'

See Also

System.Array Class, System Namespace

Array.GetValue(int, int) Method

public object GetValue(int index1, int index2);

Summary

Gets the value at the specified position in the current two-dimensional instance.

Parameters

index1
A Int32 that contains the first-dimension index of the element in the current instance to get.
index2
A Int32 that contains the second-dimension index of the element in the current instance to get.

Return Value

A Object that contains the value at the specified position in the current instance.

Exceptions

Exception TypeCondition
ArgumentExceptionThe current instance does not have exactly two dimensions.
IndexOutOfRangeExceptionAt least one of index1 or index2 is outside the range of valid indexes for the corresponding dimension of the current instance.

Description

[Note: Use the System.Array.GetLowerBound(System.Int32) and System.Array.GetUpperBound(System.Int32) methods to determine whether any of the indices are out of bounds.]

Library

ExtendedArray

See Also

System.Array Class, System Namespace

Array.GetValue(int, int, int) Method

public object GetValue(int index1, int index2, int index3);

Summary

Gets the value at the specified position in the current three-dimensional instance.

Parameters

index1
A Int32 that contains the first-dimension index of the element in the current instance to get.
index2
A Int32 that contains the second-dimension index of the element in the current instance to get.
index3
A Int32 that contains the third-dimension index of the element in the current instance to get.

Return Value

A Object that contains the value at the specified position in the current instance.

Exceptions

Exception TypeCondition
ArgumentExceptionThe current instance does not have exactly three dimensions.
IndexOutOfRangeExceptionAt least one ofindex1 or index2 or index3 is outside the range of valid indexes for the corresponding dimension of the current instance.

Description

[Note: Use the System.Array.GetLowerBound(System.Int32) and System.Array.GetUpperBound(System.Int32) methods to determine whether any of the indices are out of bounds.]

Library

ExtendedArray

See Also

System.Array Class, System Namespace

Array.IndexOf(System.Array, System.Object) Method

public static int IndexOf(Array array, object value);

Summary

Searches the specified one-dimensional Array, returning the index of the first occurrence of the specified Object.

Parameters

array
A one-dimensional Array to search.
value
A Object to locate in array.

Return Value

A Int32 containing the index of the first occurrence of value in array, if found; otherwise, array.GetLowerBound(0) - 1. [Note: For a vector, if value is not found, the return value will be -1. This provides the caller with a standard code for a failed search.]

Exceptions

Exception TypeCondition
ArgumentNullExceptionarray is null .
RankExceptionarray has more than one dimension.

Description

This version of System.Array.IndexOf(System.Array,System.Object) is equivalent to System.Array.IndexOf(System.Array,System.Object)(array, value, array.GetLowerBound(0), (array.Length - array.GetLowerBound(0)) ).

The elements will be compared using the semantics of the System.Object.Equals(System.Object) method. For user-defined types, System.Object.Equals(System.Object) is actually called.

Example

The following example demonstrates the System.Array.IndexOf(System.Array,System.Object) method.

using System;
public class ArrayIndexOfExample {
   public static void Main() {
      int[] intAry = { 0, 1, 2, 0, 1 };
      Console.Write( "The values of the array are: " );
      foreach( int i in intAry )
         Console.Write( "{0,5}", i );
      Console.WriteLine();
      int j = Array.IndexOf( intAry, 1 );
      Console.WriteLine( "The first occurrence of 1 is at index {0}", j );
   }
}
The output is

The values of the array are: 0 1 2 0 1

The first occurrence of 1 is at index 1

See Also

System.Array Class, System Namespace

Array.IndexOf(System.Array, System.Object, int) Method

public static int IndexOf(Array array, object value, int startIndex);

Summary

Searches the specified one-dimensional Array, returning the index of the first occurrence of the specified Object between the specified index and the last element.

Parameters

array
A one-dimensional Array to search.
value
A Object to locate in array.
startIndex
A Int32 that contains the index at which searching starts.

Return Value

A Int32 containing the index of the first occurrence of value in array, within the range startIndex through the last element of array, if found; otherwise, array.GetLowerBound(0) - 1. [Note: For a vector, if value is not found, the return value will be -1. This provides the caller with a standard code for the failed search.]

Exceptions

Exception TypeCondition
ArgumentNullExceptionarray is null .

ArgumentOutOfRangeExceptionstartIndex is outside the range of valid indexes for array.

RankExceptionarray has more than one dimension.

Description

This version of System.Array.IndexOf(System.Array,System.Object) is equivalent to System.Array.IndexOf(System.Array,System.Object) (array, value , startIndex, (array.Length - startIndex)).

The elements will be compared using the semantics of the System.Object.Equals(System.Object) method. For user-defined types, System.Object.Equals(System.Object) is actually called.

See Also

System.Array Class, System Namespace

Array.IndexOf(System.Array, System.Object, int, int) Method

public static int IndexOf(Array array, object value, int startIndex, int count);

Summary

Searches the specified one-dimensional Array, returning the index of the first occurrence of the specified Object in the specified range.

Parameters

array
A one-dimensional Array to search.
value
A Object to locate in array.
startIndex
A Int32 that contains the index at which searching starts.
count
A Int32 that contains the number of elements to search, beginning with startIndex.

Return Value

A Int32 containing the index of the first occurrence of value in array, within the range startIndex through startIndex + count, if found; otherwise, array.GetLowerBound(0) - 1. [Note: For a vector, if value is not found, the return value will be -1. This provides the caller with a standard code for the failed search.]

Exceptions

Exception TypeCondition
ArgumentNullExceptionarray is null .

ArgumentOutOfRangeExceptionstartIndex is outside the range of valid indices for array.

-or-

count < 0.

-or-

The sum of count and startIndex does not specify a valid range in array (i.e. count + startIndex > array.GetLowerBound(0) + array.Length).

RankExceptionarray has more than one dimension.

Description

The elements will be compared using the semantics of the System.Object.Equals(System.Object) method. For user-defined types, System.Object.Equals(System.Object) is actually called.

See Also

System.Array Class, System Namespace

Array.Initialize Method

public void Initialize();

Summary

Initializes every element of the current instance of value-type objects by calling the default constructor of that value type.

Description

This method cannot be used on reference-type arrays.

If the current instance is not a value-type Array or if the value type does not have a default constructor, the current instance is not modified.

The current instance can have any lower bound and any number of dimensions.

[Note: This method can be used only on value types that have constructors. ]

Library

RuntimeInfrastructure

See Also

System.Array Class, System Namespace

Array.LastIndexOf(System.Array, System.Object) Method

public static int LastIndexOf(Array array, object value);

Summary

Searches the specified one-dimensional Array, returning the index of the last occurrence of the specified Object.

Parameters

array
A one-dimensional Array to search.
value
A Object to locate in array.

Return Value

A Int32 containing the index of the last occurrence in array of value, if found; otherwise, array.GetLowerBound(0) - 1. [Note: For a vector, if value is not found, the return value will be -1. This provides the caller with a standard code for the failed search.]

Exceptions

Exception TypeCondition
ArgumentNullExceptionarray is null .
RankExceptionarray has more than one dimension.

Description

This version of System.Array.LastIndexOf(System.Array,System.Object) is equivalent to System.Array.LastIndexOf(System.Array,System.Object)(array, value, (array.GetLowerBound(0) + array.Length), array.Length).

The elements will be compared using the semantics of the System.Object.Equals(System.Object) method. For user-defined types, System.Object.Equals(System.Object) is actually called.

Example

The following example demonstrates the System.Array.LastIndexOf(System.Array,System.Object) method.

using System;

public class ArrayLastIndexOfExample {

   public static void Main() {
      int[] intAry = { 0, 1, 2, 0, 1 };
      Console.Write( "The values of the array are: ");
      foreach( int i in intAry )
         Console.Write( "{0,5}", i );
      Console.WriteLine();
      int j = Array.LastIndexOf( intAry, 1 );
      Console.WriteLine( "The last occurrence of 1 is at index {0}", j );
   }
}
The output is

The values of the array are: 0 1 2 0 1

The last occurrence of 1 is at index 4

See Also

System.Array Class, System Namespace

Array.LastIndexOf(System.Array, System.Object, int) Method

public static int LastIndexOf(Array array, object value, int startIndex);

Summary

Searches the specified one-dimensional Array, returning the index of the last occurrence of the specified Object between the specified index and the first element.

Parameters

array
A one-dimensional Array to search.
value
A Object to locate in array.
startIndex
A Int32 that contains the index at which searching starts.

Return Value

A Int32 containing the index of the last occurrence of value in the range startIndex through the lower bound of array, if found; otherwise, array.GetLowerBound(0) - 1. [Note: For a vector, if value is not found, the return value will be -1. This provides the caller with a standard code for the failed search.]

Exceptions

Exception TypeCondition
ArgumentNullExceptionarray is null .

ArgumentOutOfRangeExceptionstartIndex is outside the range of valid indices for array.

RankExceptionarray has more than one dimension.

Description

This version of System.Array.LastIndexOf(System.Array,System.Object) is equivalent to System.Array.LastIndexOf(System.Array,System.Object)( array, value, startIndex, (array.Length - startIndex) ).

The elements will be compared using the semantics of the System.Object.Equals(System.Object) method. For user-defined types, System.Object.Equals(System.Object) is actually called.

See Also

System.Array Class, System Namespace

Array.LastIndexOf(System.Array, System.Object, int, int) Method

public static int LastIndexOf(Array array, object value, int startIndex, int count);

Summary

Searches the specified one-dimensional Array, returning the index of the last occurrence of the specified Object in the specified range.

Parameters

array
A one-dimensional Array to search.
value
A Object to locate in array.
startIndex
A Int32 that contains the index at which searching starts.
count
A Int32 that contains the number of elements to search, beginning with startIndex .

Return Value

A Int32 containing the index of the last occurrence of value in array, within the range startIndex + count through startIndex, if found; otherwise, array.GetLowerBound(0) - 1. [Note: For a vector, if value is not found, the return value will be -1. This provides the caller with a standard code for the failed search.]

Exceptions

Exception TypeCondition
ArgumentNullExceptionarray is null .

ArgumentOutOfRangeExceptionstartIndex is outside the range of valid indices for array.

-or-

count < 0.

-or-

count and startIndex do not specify a valid range in array.

RankExceptionarray has more than one dimension.

Description

The elements will be compared using the semantics of the System.Object.Equals(System.Object) method. For user-defined types, System.Object.Equals(System.Object) is actually called.

See Also

System.Array Class, System Namespace

Array.Reverse(System.Array) Method

public static void Reverse(Array array);

Summary

Reverses the sequence of the elements in the specified one-dimensional Array.

Parameters

array
The one-dimensional Array to reverse.

Exceptions

Exception TypeCondition
ArgumentNullExceptionarray is null .
RankExceptionarray has more than one dimension.

Description

This version of System.Array.Reverse(System.Array) is equivalent to System.Array.Reverse(System.Array)(array, array.GetLowerBound(0), array.Length).

See Also

System.Array Class, System Namespace

Array.Reverse(System.Array, int, int) Method

public static void Reverse(Array array, int index, int length);

Summary

Reverses the sequence of the elements in the specified range of the specified one-dimensional Array.

Parameters

array
The one-dimensional Array to reverse.
index
A Int32 that contains the index at which reversing starts.
length
A Int32 that contains the number of elements to reverse.

Exceptions

Exception TypeCondition
ArgumentNullExceptionarray is null .
RankExceptionarray is multidimensional.
ArgumentOutOfRangeExceptionindex < array.GetLowerBound(0).

length < 0.

ArgumentExceptionindex and length do not specify a valid range in array (i.e. index + length > array.GetLowerBound(0) + array.Length).

Example

The following example demonstrates the System.Array.Reverse(System.Array) method.

using System;
public class ArrayReverseExample {
   public static void Main() {
      string[] strAry = { "one", "two", "three" };
      Console.Write( "The elements of the array are:");
      foreach( string str in strAry )
         Console.Write( " {0}", str );
      Array.Reverse( strAry );
      Console.WriteLine();
      Console.WriteLine( "After reversing the array," );
      Console.Write( "the elements of the array are:");
      foreach( string str in strAry )
         Console.Write( " {0}", str );
   }
}
The output is

The elements of the array are: one two three

After reversing the array,

the elements of the array are: three two one

See Also

System.Array Class, System Namespace

Array.SetValue(System.Object, int) Method

public void SetValue(object value, int index);

Summary

Sets the value of the element at the specified position in the current one-dimensional instance.

Parameters

value
A Object that contains the new value for the specified element.
index
A Int32 that contains the index of the element whose value is to be set.

Exceptions

Exception TypeCondition
ArgumentExceptionThe current instance has more than one dimension.

-or-

value is not assignment-compatible with the element type of the current instance.

IndexOutOfRangeExceptionindex is outside the range of valid indices for the current instance.

Description

[Note: Use the System.Array.GetLowerBound(System.Int32) and System.Array.GetUpperBound(System.Int32) methods to determine whether index is out of bounds.

For more information regarding valid conversions that will be performed by this method, see Convert.

]

See Also

System.Array Class, System Namespace

Array.SetValue(System.Object, int, int) Method

public void SetValue(object value, int index1, int index2);

Summary

Sets the value of the element at the specified position in the current two-dimensional instance.

Parameters

value
A Object that contains the new value for the specified element.
index1
A Int32 that contains the first-dimension index of the element in the current instance to set.
index2
A Int32 that contains the second-dimension index of the element in the current instance to set.

Exceptions

Exception TypeCondition
ArgumentExceptionThe current instance does not have exactly two dimensions.

-or-

value is not assignment-compatible with the element type of the current instance.

IndexOutOfRangeExceptionAt least one of index1 or index2 is outside the range of valid indices for the corresponding dimension of the current instance.

Description

[Note: For more information regarding valid conversions that will be performed by this method, see Convert.

Use the System.Array.GetLowerBound(System.Int32) and System.Array.GetUpperBound(System.Int32) methods to determine whether any of the indices are out of bounds.

]

Library

ExtendedArray

See Also

System.Array Class, System Namespace

Array.SetValue(System.Object, int, int, int) Method

public void SetValue(object value, int index1, int index2, int index3);

Summary

Sets the value of the element at the specified position in the current three-dimensional instance.

Parameters

value
A Object that contains the new value for the specified element.
index1
A Int32 that contains the first-dimension index of the element in the current instance to set.
index2
A Int32 that contains the second-dimension index of the element in the current instance to set.
index3
A Int32 that contains the third-dimension index of the element in the current instance to set.

Exceptions

Exception TypeCondition
ArgumentExceptionThe current instance does not have exactly three dimensions.

-or-

value is not assignment-compatible with the element type of the current instance.

IndexOutOfRangeExceptionAt least one of index1, index2, or index3 is outside the range of valid indices for the corresponding dimension of the current instance.

Description

[Note: For more information regarding valid conversions that will be performed by this method, see Convert.

Use the System.Array.GetLowerBound(System.Int32) and System.Array.GetUpperBound(System.Int32) methods to determine whether any of the indices are out of bounds.

]

Library

ExtendedArray

See Also

System.Array Class, System Namespace

Array.SetValue(System.Object, int[]) Method

public void SetValue(object value, int[] indices);

Summary

Sets the value of the element at the specified position in the current multidimensional instance.

Parameters

value
A Object that contains the new value for the specified element.
indices
A one-dimensional array of Int32 objects that contains the indices that specify the position of the element in the current instance to set.

Exceptions

Exception TypeCondition
ArgumentNullExceptionindices is null .
ArgumentExceptionThe number of dimensions in the current instance is not equal to the number of elements in indices.

-or-

value is not assignment-compatible with the element type of the current instance.

IndexOutOfRangeExceptionAt least one element in indices is outside the range of valid indices for the corresponding dimension of the current instance.

Description

The number of elements in indices is required to be equal to the number of dimensions in the current instance. All elements in indices collectively specify the position of the desired element in the current instance.

[Note: For more information regarding valid conversions that will be performed by this method, see Convert.

Use the System.Array.GetLowerBound(System.Int32) and System.Array.GetUpperBound(System.Int32) methods to determine whether any of the values in indices is out of bounds.

]

Library

ExtendedArray

See Also

System.Array Class, System Namespace

Array.Sort(System.Array) Method

public static void Sort(Array array);

Summary

Sorts the elements of the specified one-dimensional Array.

Parameters

array
A one-dimensional Array to sort.

Exceptions

Exception TypeCondition
ArgumentNullExceptionarray is null .
RankExceptionarray has more than one dimension.
ArgumentExceptionOne or more elements in array do not implement the IComparable interface.

Description

This version of System.Array.Sort(System.Array) is equivalent to System.Array.Sort(System.Array)(array, null , array.GetLowerBound(0), array.Length, null ).

Each element of array is required to implement the IComparable interface to be capable of comparisons with every other element in array.

Example

This example demonstrates the System.Array.Sort(System.Array) method.

using System;
public class ArraySortExample {
   public static void Main() {
      string[] strAry = { "All's", "well", "that", "ends", "well" };
      Console.Write( "The original string array is: " );
      foreach ( String str in strAry )
         Console.Write( str + " " );
      Console.WriteLine();
      Array.Sort( strAry );
      Console.Write( "The sorted string array is: " );
      foreach ( string str in strAry )
         Console.Write( str + " " );
   }
}
The output is

The original string array is: All's well that ends well

The sorted string array is: All's ends that well well

See Also

System.Array Class, System Namespace

Array.Sort(System.Array, System.Array) Method

public static void Sort(Array keys, Array items);

Summary

Sorts the specified pair of one-dimensional Array objects (one containing a set of keys and the other containing corresponding items) based on the keys in the first specified Array.

Parameters

keys
A one-dimensional Array that contains the keys to sort.
items
A one-dimensional Array that contains the items that correspond to each of element of keys. Specify a null reference to sort only keys.

Exceptions

Exception TypeCondition
ArgumentNullExceptionkeys is null .

RankExceptionkeys has more than one dimension.

-or-

items is not a null reference and has more than one dimension.

ArgumentExceptionitems is not a null reference, and keys.GetLowerBound(0) does not equal items.GetLowerBound(0).

-or-

items is not a null reference, and keys.Length > items.Length.

-or-

One or more elements in keys do not implement the IComparable interface.

Description

This version of System.Array.Sort(System.Array) is equivalent to System.Array.Sort(System.Array)(keys, items, keys.GetLowerBound(0), keys.Length, null ).

Each key in keys is required to have a corresponding item in items. The sort is performed according to the order of keys . After a key is repositioned during the sort, the corresponding item in items is similarly repositioned. Only keys.Length elements of items are sorted. Therefore, items is sorted according to the arrangement of the corresponding keys in keys. If the sort is not successfully completed, the results are unspecified.

Each element of keys is required to implement the IComparable interface to be capable of comparisons with every other element in keys.

Example

This example demonstrates the System.Array.Sort(System.Array) method.

using System;
public class ArraySortExample {
   public static void Main() {
      string[] strAry = { "All's", "well", "that", "ends", "well" };
      int[] intAry = { 3, 4, 0, 1, 2 };
      Console.Write( "The original string array is: " );
      foreach ( string str in strAry )
         Console.Write( str + " " );
      Console.WriteLine();
      Console.Write( "The key array is: " );
      foreach ( int i in intAry )
         Console.Write( i + " " );
      Console.WriteLine();
      Array.Sort( intAry, strAry );
      Console.Write( "The sorted string array is: " );
      foreach ( string str in strAry )
         Console.Write( str + " " );
   }
}
The output is

The original string array is: All's well that ends well

The key array is: 3 4 0 1 2

The sorted string array is: that ends well All's well

See Also

System.Array Class, System Namespace

Array.Sort(System.Array, int, int) Method

public static void Sort(Array array, int index, int length);

Summary

Sorts the elements in the specified range of the specified one-dimensional Array.

Parameters

array
A one-dimensional Array to sort.
index
A Int32 that contains the index at which sorting starts.
length
A Int32 that contains the number of elements to sort.

Exceptions

Exception TypeCondition
ArgumentNullExceptionarray is null .
RankExceptionarray has more than one dimension.
ArgumentOutOfRangeExceptionindex < array.GetLowerBound(0).

-or-

length < 0.

ArgumentExceptionindex and length do not specify a valid range in array.

-or-

One or more elements in array do not implement the IComparable interface.

Description

This version of System.Array.Sort(System.Array) is equivalent to System.Array.Sort(System.Array)(array, null , index, length, null ).

Each element of array is required to implement the IComparable interface to be capable of comparisons with every other element in array. If the sort is not successfully completed, the results are unspecified.

See Also

System.Array Class, System Namespace

Array.Sort(System.Array, System.Array, int, int) Method

public static void Sort(Array keys, Array items, int index, int length);

Summary

Sorts the specified ranges of the specified pair of one-dimensional Array objects (one containing a set of keys and the other containing corresponding items) based on the keys in the first specified Array.

Parameters

keys
A one-dimensional Array that contains the keys to sort.
items
A one-dimensional Array that contains the items that correspond to each element in keys. Specify a null reference to sort only keys.
index
A Int32 that contains the index at which sort begins.
length
A Int32 that contains the number of elements to sort.

Exceptions

Exception TypeCondition
ArgumentNullExceptionkeys is null .

RankExceptionkeys has more than one dimension.

-or-

items is not a null reference and has more than one dimension.

ArgumentOutOfRangeExceptionindex < keys.GetLowerBound(0).

-or-

length < 0.

ArgumentExceptionitems is not a null reference, and keys.GetLowerBound(0) does not equal items.GetLowerBound(0).

-or-

index and length do not specify a valid range in key.

-or-

items is not a null reference, and index and length do not specify a valid range in items.

-or-

One or more elements in keys do not implement the IComparable interface.

Description

This version of System.Array.Sort(System.Array) is equivalent to System.Array.Sort(System.Array)(keys, items, index, length, null ).

Each key in keys is required to have a corresponding item in items. The sort is performed according to the order of keys . After a key is repositioned during the sort, the corresponding item in items is similarly repositioned. Therefore, items is sorted according to the arrangement of the corresponding keys in keys. If the sort is not successfully completed, the results are undefined.

Each element of keys is required to implement the IComparable interface to be capable of comparisons with every other element in keys.

See Also

System.Array Class, System Namespace

Array.Sort(System.Array, System.Collections.IComparer) Method

public static void Sort(Array array, IComparer comparer);

Summary

Sorts the elements in the specified one-dimensional Array using the specified IComparer implementation.

Parameters

array
The one-dimensional Array to sort.
comparer
The IComparer implementation to use when comparing elements. Specify a null reference to use the IComparable implementation of each element.

Exceptions

Exception TypeCondition
ArgumentNullExceptionarray is null .
RankExceptionarray has more than one dimension.
ArgumentExceptioncomparer is a null reference, and one or more elements in array do not implement the IComparable interface.

Description

This version of System.Array.Sort(System.Array) is equivalent to System.Array.Sort(System.Array)(array, null , array.GetLowerBound(0), array.Length, comparer).

If comparer is a null reference, each element of array is required to implement the IComparable interface to be capable of comparisons with every other element in array. If the sort is not successfully completed, the results are unspecified.

See Also

System.Array Class, System Namespace

Array.Sort(System.Array, System.Array, System.Collections.IComparer) Method

public static void Sort(Array keys, Array items, IComparer comparer);

Summary

Sorts the specified pair of one-dimensional Array objects (one containing a set of keys and the other containing corresponding items) based on the keys in the first specified Array using the specified IComparer implementation.

Parameters

keys
A one-dimensional Array that contains the keys to sort.
items
A one-dimensional Array that contains the items that correspond to each element in keys. Specify a null reference to sort only keys.

comparer
The IComparer implementation to use when comparing elements. Specify a null reference to use the IComparable implementation of each element.

Exceptions

Exception TypeCondition
ArgumentNullExceptionkeys is null .

RankExceptionkeys has more than one dimension.

-or-

items is not a null reference and has more than one dimension.

ArgumentExceptionitems is not a null reference, and keys.GetLowerBound(0) does not equal items.GetLowerBound(0).

-or-

items is not a null reference, and keys.Length > items.Length.

-or-

comparer is a null reference, and one or more elements in the keys do not implement the IComparable interface.

Description

This version of System.Array.Sort(System.Array) is equivalent to System.Array.Sort(System.Array)(keys, items, keys.GetLowerBound(0), keys.Length, comparer).

Each key in keys is required to have a corresponding item in items. The sort is performed according to the order of keys . After a key is repositioned during the sort, the corresponding item in items is similarly repositioned. Only keys.Length elements of items are sorted. Therefore, items is sorted according to the arrangement of the corresponding keys in keys. If the sort is not successfully completed, the results are unspecified.

If comparer is a null reference, each element of keys is required to implement the IComparable interface to be capable of comparisons with every other element in keys.

See Also

System.Array Class, System Namespace

Array.Sort(System.Array, int, int, System.Collections.IComparer) Method

public static void Sort(Array array, int index, int length, IComparer comparer);

Summary

Sorts the elements in the specified section of the specified one-dimensional Array using the specified IComparer implementation.

Parameters

array
A one-dimensional Array to sort.
index
A Int32 that contains the index at which sorting starts.
length
A Int32 that contains the number of elements to sort.
comparer
The IComparer implementation to use when comparing elements. Specify a null reference to use the IComparable implementation of each element.

Exceptions

Exception TypeCondition
ArgumentNullExceptionarray is null .
RankExceptionarray has more than one dimension.
ArgumentOutOfRangeExceptionindex < array.GetLowerBound(0).

-or-

length < 0.

ArgumentExceptionindex and length do not specify a valid range in array.

-or-

comparer is a null reference, and one or more elements in array do not implement the IComparable interface.

Description

This version of System.Array.Sort(System.Array) is equivalent to System.Array.Sort(System.Array)(array, null , index, length, comparer).

If comparer is a null reference, each element of array is required to implement the IComparable interface to be capable of comparisons with every other element in array. If the sort is not successfully completed, the results are unspecified.

See Also

System.Array Class, System Namespace

Array.Sort(System.Array, System.Array, int, int, System.Collections.IComparer) Method

public static void Sort(Array keys, Array items, int index, int length, IComparer comparer);

Summary

Sorts the specified range of the specified pair of one-dimensional Array objects (one containing a set of keys and the other containing corresponding items) based on the keys in the first specified Array using the specified IComparer implementation.

Parameters

keys
A one-dimensional Array that contains the keys to sort.
items
A one-dimensional Array that contains the items that correspond to each element of keys. Specify a null reference to sort only keys.

index
A Int32 that contains the index at which sorting starts.
length
A Int32 that contains the number of elements to sort.
comparer
The IComparer implementation to use when comparing elements. Specify a null reference to use the IComparable implementation of each element.

Exceptions

Exception TypeCondition
ArgumentNullExceptionkeys is null .

RankExceptionkeys has more than one dimension.

-or-

items is not a null reference and has more than one dimension.

ArgumentOutOfRangeExceptionindex < keys.GetLowerBound(0).

-or-

length < 0.

ArgumentExceptionitems is not a null reference, and keys.GetLowerBound(0) does not equal items.GetLowerBound(0).

-or-

index and length do not specify a valid range in key.

-or-

items is not a null reference, and index and length do not specify a valid range in items.

-or-

comparer is a null reference, and one or more elements in keys do not implement the IComparable interface.

Description

Each key in keys is required to have a corresponding item in items. The sort is performed according to the order of keys. After a key is repositioned during the sort, the corresponding item in items is similarly repositioned. Only keys.Length elements of items will be sorted. Therefore, items is sorted according to the arrangement of the corresponding keys in keys. If the sort is not successfully completed, the results are undefined.

If comparer is a null reference, each element of keys is required to implement the IComparable interface to be capable of comparisons with every other element in keys.

See Also

System.Array Class, System Namespace

Array.System.Collections.IList.Add Method

int IList.Add(object value);

Summary

Implemented to support the IList interface. [Note: For more information, see System.Collections.IList.Add.]

See Also

System.Array Class, System Namespace

Array.System.Collections.IList.Clear Method

void IList.Clear();

Summary

Implemented to support the IList interface. [Note: For more information, see System.Collections.IList.Clear.]

See Also

System.Array Class, System Namespace

Array.System.Collections.IList.Contains Method

bool IList.Contains(object value);

Summary

Implemented to support the IList interface. [Note: For more information, see System.Collections.IList.Contains.]

See Also

System.Array Class, System Namespace

Array.System.Collections.IList.IndexOf Method

int IList.IndexOf(object value);

Summary

Implemented to support the IList interface. [Note: For more information, see System.Collections.IList.IndexOf.]

See Also

System.Array Class, System Namespace

Array.System.Collections.IList.Insert Method

void IList.Insert(int index, object value);

Summary

Implemented to support the IList interface. [Note: For more information, see System.Collections.IList.Insert.]

See Also

System.Array Class, System Namespace

Array.System.Collections.IList.Remove Method

void IList.Remove(object value);

Summary

Implemented to support the IList interface. [Note: For more information, see System.Collections.IList.Remove.]

See Also

System.Array Class, System Namespace

Array.System.Collections.IList.RemoveAt Method

void IList.RemoveAt(int index);

Summary

Implemented to support the IList interface. [Note: For more information, see System.Collections.IList.RemoveAt.]

See Also

System.Array Class, System Namespace

Array.IsFixedSize Property

bool IList.IsFixedSize { get; }

Summary

Implemented to support the IList interface. [Note: For more information, see System.Collections.IList.IsFixedSize.]

See Also

System.Array Class, System Namespace

Array.IsReadOnly Property

bool IList.IsReadOnly { get; }

Summary

Implemented to support the IList interface. [Note: For more information, see System.Collections.IList.IsReadOnly.]

See Also

System.Array Class, System Namespace

Array.IsSynchronized Property

bool ICollection.IsSynchronized { get; }

Summary

Implemented to support the ICollection interface. [Note: For more information, see System.Collections.ICollection.IsSynchronized.]

See Also

System.Array Class, System Namespace

Array.Length Property

public int Length { get; }

Summary

Gets the total number of elements in all the dimensions of the current instance.

Property Value

A Int32 that contains the total number of elements in all the dimensions of the current instance.

Description

This property is read-only.

See Also

System.Array Class, System Namespace

Array.LongLength Property

public long LongLength {get;}

Summary

Gets the total number of elements in all the dimensions of the current instance.

Property Value

A Int64 value containing the length of the array.

Description

This property is read-only.

[Note: For additional information, see System.Array.Length.]

See Also

System.Array Class, System Namespace

Array.Rank Property

public int Rank { get; }

Summary

Gets the rank (number of dimensions) of the current instance.

Property Value

A Int32 that contains the rank (number of dimensions) of the current instance.

Description

This property is read-only.

See Also

System.Array Class, System Namespace

Array.SyncRoot Property

object ICollection.SyncRoot { get; }

Summary

Implemented to support the ICollection interface. [Note: For more information, see System.Collections.ICollection.SyncRoot.]

See Also

System.Array Class, System Namespace

Array.System.Collections.ICollection.Count Property

int ICollection.Count { get; }

Summary

Implemented to support the ICollection interface. [Note: For more information, see System.Collections.ICollection.Count.]

See Also

System.Array Class, System Namespace

Array.System.Collections.IList.Item Property

public virtual object this[int index] { get; set; }

Summary

Implemented to support the IList interface. [Note: For more information, see System.Collections.IList.Item.]

See Also

System.Array Class, System Namespace