C# Array SetValue(Object, Int64[]) Array
Description
Array SetValue(Object, Int64[])
sets a value to the element
at the specified position in the multidimensional Array. The indexes are
specified as an array of 64-bit integers.
Syntax
Array.SetValue(Object, Int64[])
has the following syntax.
[ComVisibleAttribute(false)]/* ww w.ja va 2 s. co m*/
public void SetValue(
Object value,
params long[] indices
)
Parameters
Array.SetValue(Object, Int64[])
has the following parameters.
value
- The new value for the specified element.indices
- A one-dimensional array of 64-bit integers that represent the indexes specifying the position of the element to set.
Returns
Array.SetValue(Object, Int64[])
method returns
Example
The following code example demonstrates how to set and get a specific value in a one-dimensional or multidimensional array.
using System;/*from w w w . j a v a 2s. com*/
public class SamplesArray {
public static void Main() {
// Creates and initializes a one-dimensional array.
String[] myArr1 = new String[5];
// Creates and initializes a seven-dimensional array.
String[,,,,,,] myArr7 = new String[5,5,5,5,5,5,5];
// Sets the element at index 1,2,3,0,1,2,3.
int[] myIndices = new int[7] { 1, 2, 3, 0, 1, 2, 3 };
myArr7.SetValue( "one-two-three-zero-one-two-three", myIndices );
Console.WriteLine( "[1,2,3,0,1,2,3]: {0}", myArr7.GetValue( myIndices ) );
}
}
The code above generates the following result.