Type.GetGenericArguments メソッド
アセンブリ: mscorlib (mscorlib.dll 内)

Dim instance As Type Dim returnValue As Type() returnValue = instance.GetGenericArguments
ジェネリック型の型引数を表す Type オブジェクト。現在の型がジェネリック型でない場合は空の配列を返します。

配列の要素は、ジェネリック型の型引数のリスト内に現れる順番どおりに返されます。
-
現在の型がクローズ構築型である (つまり、ContainsGenericParameters プロパティが false を返す) 場合は、GetGenericArguments メソッドによって返される配列にジェネリック型定義のジェネリック型パラメータに割り当てられた型が含まれます。
-
現在の型がオープン構築型 (つまり、ContainsGenericParameters プロパティが true を返す) である場合は、すべての型パラメータおよび包含するジェネリック型またはジェネリック メソッドの型パラメータに対して、特定の型が割り当てられていることはないので、配列に両方の型および型パラメータが含まれます。IsGenericParameter プロパティを使用して識別します。このシナリオの詳細については、ContainsGenericParameters プロパティのコード例を参照してください。
ジェネリック リフレクションで使用される用語の一定の条件の一覧については、IsGenericType のプロパティの解説を参照してください。

GetGenericArguments メソッドを使用し、構築型の型引数およびそのジェネリック型定義の型パラメータを表示するコード例を次に示します。
次のコード例は IsGenericTypeDefinition プロパティの例の一部です。
If t.IsGenericType Then ' If this is a generic type, display the type arguments. ' Dim typeArguments As Type() = t.GetGenericArguments() Console.WriteLine(vbTab & "List type arguments (" _ & typeArguments.Length & "):") For Each tParam As Type In typeArguments ' If this is a type parameter, display its position. ' If tParam.IsGenericParameter Then Console.WriteLine(vbTab & vbTab & tParam.ToString() _ & vbTab & "(unassigned - parameter position " _ & tParam.GenericParameterPosition & ")") Else Console.WriteLine(vbTab & vbTab & tParam.ToString()) End If Next tParam End If
if (t.IsGenericType) { // If this is a generic type, display the type arguments. // Type[] typeArguments = t.GetGenericArguments(); Console.WriteLine("\tList type arguments ({0}):", typeArguments.Length); foreach (Type tParam in typeArguments) { // If this is a type parameter, display its // position. // if (tParam.IsGenericParameter) { Console.WriteLine("\t\t{0}\t(unassigned - parameter position {1})" , tParam, tParam.GenericParameterPosition); } else { Console.WriteLine("\t\t{0}", tParam); } } }
if ( t->IsGenericType ) { // If this is a generic type, display the type arguments. // array<Type^>^typeArguments = t->GetGenericArguments(); Console::WriteLine( L"\tList type arguments ({0}):", typeArguments->Length ); System::Collections::IEnumerator^ myEnum = typeArguments->GetEnumerator(); while ( myEnum->MoveNext() ) { Type^ tParam = safe_cast<Type^>(myEnum->Current); // If this is a type parameter, display its // position. // if ( tParam->IsGenericParameter ) { Console::WriteLine( L"\t\t{0}\t(unassigned - parameter position {1})", tParam, tParam->GenericParameterPosition ); } else { Console::WriteLine( L"\t\t{0}", tParam ); } } }
if (t.get_IsGenericType()) { // If this is a generic type, display the type arguments. Type typeArguments[] = t.GetGenericArguments(); Console.WriteLine("\tList type arguments ({0}):", (Int32)typeArguments.get_Length()); for (int iCtr = 0; iCtr < typeArguments.get_Length(); iCtr++) { Type tParam = typeArguments[iCtr]; // If this is a type parameter, display its // position. if (tParam.get_IsGenericParameter()) { Console.WriteLine("\t\t{0}\t(unassigned - parameter " + "position {1})", tParam, (Int32)tParam.get_GenericParameterPosition()); } else { Console.WriteLine("\t\t{0}", tParam); } } }

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からType.GetGenericArguments メソッドを検索する場合は、下記のリンクをクリックしてください。

- Type.GetGenericArguments メソッドのページへのリンク