Share via


Type.GetTypeArray メソッド

指定した配列内のオブジェクトの型を取得します。

Public Shared Function GetTypeArray( _
   ByVal args() As Object _) As Type()
[C#]
public static Type[] GetTypeArray(object[] args);
[C++]
public: static Type* GetTypeArray(Object* args __gc[]) [];
[JScript]
public static function GetTypeArray(
   args : Object[]) : Type[];

パラメータ

  • args
    型を確認する対象のオブジェクトの配列。

戻り値

args 内の対応する要素の型を表す Type オブジェクトの配列。

例外

例外の種類 条件
ArgumentNullException args が null 参照 (Visual Basic では Nothing) です。
TargetInvocationException クラス初期化子が呼び出され、そのうちの少なくとも 1 つが例外をスローしました。

解説

要求された型がパブリックではなく、呼び出し元に現在のアセンブリ外の非パブリック オブジェクトに対する ReflectionPermission がない場合、このメソッドは結果配列の対応する要素に対して null 参照 (Visual Basic では Nothing) を返します。

使用例

 
Dim myObject(2) As Object
myObject(0) = 66
myObject(1) = "puri"
myObject(2) = 33.33
' Get the array of 'Type' class objects.
Dim myTypeArray As Type() = Type.GetTypeArray(myObject)
Console.WriteLine("Full names of the 'Type' objects in the array are:")
Dim h As Integer
For h = 0 To myTypeArray.Length - 1
   Console.WriteLine(myTypeArray(h).FullName)
Next h

[C#] 
Object[] myObject = new Object[3];
myObject[0] = 66;
myObject[1] = "puri";
myObject[2] = 33.33;
// Get the array of 'Type' class objects.
Type[] myTypeArray = Type.GetTypeArray(myObject);
Console.WriteLine("Full names of the 'Type' objects in the array are:");
for(int h = 0; h < myTypeArray.Length ; h++)
{
    Console.WriteLine(myTypeArray[h].FullName);
}

[C++] 
Object* myObject[] = new Object*[3];
myObject->Item[0] = __box(66);
myObject->Item[1] = S"puri";
myObject->Item[2] = __box(33.33);
// Get the array of 'Type' class objects.
Type*  myTypeArray[] = Type::GetTypeArray(myObject);
Console::WriteLine(S"Full names of the 'Type' objects in the array are:");
for (int h = 0; h < myTypeArray->Length ; h++) {
   Console::WriteLine(myTypeArray[h]->FullName);
}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, Common Language Infrastructure (CLI) Standard

参照

Type クラス | Type メンバ | System 名前空間 | ReflectionPermission