Array.GetValue Method (Int32, Int32)

 

Gets the value at the specified position in the two-dimensional Array. The indexes are specified as 32-bit integers.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

member GetValue : 
        index1:int *
        index2:int -> Object

Parameters

index1
Type: System.Int32

A 32-bit integer that represents the first-dimension index of the Array element to get.

index2
Type: System.Int32

A 32-bit integer that represents the second-dimension index of the Array element to get.

Return Value

Type: System.Object

The value at the specified position in the two-dimensional Array.

Exception Condition
ArgumentException

The current Array does not have exactly two dimensions.

IndexOutOfRangeException

Either index1 or index2 is outside the range of valid indexes for the corresponding dimension of the current Array.

The GetLowerBound and GetUpperBound methods can determine whether any of the indexes is out of bounds.

This method is an O(1) operation.

The following code example demonstrates how to set and get a specific value in a one-dimensional or multidimensional array.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top
Show: