現在の Array 内の指定した要素の値を取得します。インデックスは 32 ビット整数値の配列として指定します。
オーバーロードの一覧
1 次元 Array 内の指定した位置にある値を取得します。インデックスは 32 ビット整数値として指定します。
.NET Compact Framework でもサポート。
[Visual Basic] Overloads Public Function GetValue(Integer) As Object
[JScript] public function GetValue(int) : Object;
多次元 Array 内の指定した位置にある値を取得します。
.NET Compact Framework でもサポート。
[Visual Basic] Overloads Public Function GetValue(ParamArray Integer()) As Object
1 次元 Array 内の指定した位置にある値を取得します。インデックスは 64 ビット整数値として指定します。
[Visual Basic] Overloads Public Function GetValue(Long) As Object
[JScript] public function GetValue(long) : Object;
多次元 Array 内の指定した位置にある値を取得します。インデックスは 64 ビット整数値の配列として指定します。
[Visual Basic] Overloads Public Function GetValue(ParamArray Long()) As Object
2 次元 Array 内の指定した位置にある値を取得します。インデックスは 32 ビット整数値として指定します。
[Visual Basic] Overloads Public Function GetValue(Integer, Integer) As Object
2 次元 Array 内の指定した位置にある値を取得します。インデックスは 64 ビット整数値として指定します。
[Visual Basic] Overloads Public Function GetValue(Long, Long) As Object
3 次元 Array 内の指定した位置にある値を取得します。インデックスは 32 ビット整数値として指定します。
[Visual Basic] Overloads Public Function GetValue(Integer, Integer, Integer) As Object
3 次元 Array 内の指定した位置にある値を取得します。インデックスは 64 ビット整数値として指定します。
[Visual Basic] Overloads Public Function GetValue(Long, Long, Long) As Object
[JScript] public function GetValue(long, long, long) : Object;
使用例
[Visual Basic, C#, C++] 1 次元配列または多次元配列の特定の値を設定および取得する方法を次のコード例に示します。
[Visual Basic, C#, C++] メモ ここでは、GetValue のオーバーロード形式のうちの 1 つだけについて、使用例を示します。その他の例については、各オーバーロード形式のトピックを参照してください。
Imports System
Public Class SamplesArray
Public Shared Sub Main()
' Creates and initializes a one-dimensional array.
Dim myArr1(4) As [String]
' Sets the element at index 3.
myArr1.SetValue("three", 3)
Console.WriteLine("[3]: {0}", myArr1.GetValue(3))
' Creates and initializes a two-dimensional array.
Dim myArr2(5, 5) As [String]
' Sets the element at index 1,3.
myArr2.SetValue("one-three", 1, 3)
Console.WriteLine("[1,3]: {0}", myArr2.GetValue(1, 3))
' Creates and initializes a three-dimensional array.
Dim myArr3(5, 5, 5) As [String]
' Sets the element at index 1,2,3.
myArr3.SetValue("one-two-three", 1, 2, 3)
Console.WriteLine("[1,2,3]: {0}", myArr3.GetValue(1, 2, 3))
' Creates and initializes a seven-dimensional array.
Dim myArr7(5, 5, 5, 5, 5, 5, 5) As [String]
' Sets the element at index 1,2,3,0,1,2,3.
Dim myIndices() As Integer = {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))
End Sub 'Main
End Class 'SamplesArray
'This code produces the following output.
'
'[3]: three
'[1,3]: one-three
'[1,2,3]: one-two-three
'[1,2,3,0,1,2,3]: one-two-three-zero-one-two-three
[C#]
using System;
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 ) );
// Creates and initializes a two-dimensional array.
String[,] myArr2 = new String[5,5];
// Sets the element at index 1,3.
myArr2.SetValue( "one-three", 1, 3 );
Console.WriteLine( "[1,3]: {0}", myArr2.GetValue( 1, 3 ) );
// Creates and initializes a three-dimensional array.
String[,,] myArr3 = new String[5,5,5];
// Sets the element at index 1,2,3.
myArr3.SetValue( "one-two-three", 1, 2, 3 );
Console.WriteLine( "[1,2,3]: {0}", myArr3.GetValue( 1, 2, 3 ) );
// 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 ) );
}
}
/*
This code produces the following output.
[3]: three
[1,3]: one-three
[1,2,3]: one-two-three
[1,2,3,0,1,2,3]: one-two-three-zero-one-two-three
*/
[C++]
#using <mscorlib.dll>
using namespace System;
int main() {
// Creates and initializes a one-dimensional array.
String* myArr1[] = new String*[5];
// Sets the element at index 3.
myArr1->SetValue( S"three", 3 );
Console::WriteLine( S"[3]: {0}", myArr1->GetValue( 3 ) );
// Creates and initializes a two-dimensional array.
String* myArr2[,] = new String*[5,5];
// Sets the element at index 1,3.
myArr2->SetValue( S"one-three", 1, 3 );
Console::WriteLine( S"[1,3]: {0}", myArr2->GetValue( 1, 3 ) );
// Creates and initializes a three-dimensional array.
String* myArr3[,,] = new String*[5,5,5];
// Sets the element at index 1,2,3.
myArr3->SetValue( S"one-two-three", 1, 2, 3 );
Console::WriteLine( S"[1,2,3]: {0}", myArr3->GetValue( 1, 2, 3 ) );
// 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.
Int32 myIndices[] = { 1, 2, 3, 0, 1, 2, 3 };
myArr7->SetValue( S"one-two-three-zero-one-two-three", myIndices);
Console::WriteLine( S"[1,2,3,0,1,2,3]: {0}", myArr7->GetValue( myIndices ) );
}
/*
This code produces the following output.
[3]: three
[1,3]: one-three
[1,2,3]: one-two-three
[1,2,3,0,1,2,3]: one-two-three-zero-one-two-three
*/
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。