C# Array SetValue(Object, Int64)
Description
Array SetValue(Object, Int64)
sets a value to the element
at the specified position in the one-dimensional Array. The index is specified
as a 64-bit integer.
Syntax
Array.SetValue(Object, Int64)
has the following syntax.
[ComVisibleAttribute(false)]//w ww . j a v a2 s.com
public void SetValue(
Object value,
long index
)
Parameters
Array.SetValue(Object, Int64)
has the following parameters.
value
- The new value for the specified element.index
- A 64-bit integer that represents the position of the Array 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;//w ww. ja v a 2 s. c o m
public class SamplesArray {
public static void Main() {
// Creates and initializes a one-dimensional array.
String[] myArr1 = new String[5];
// Sets the element at index 3.
myArr1.SetValue( "three", 3 );
Console.WriteLine( "[3]: {0}", myArr1.GetValue( 3 ) );
}
}
The code above generates the following result.