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

Dim instance As MethodInfo Dim returnValue As Type() returnValue = instance.GetGenericArguments
ジェネリック メソッドの型引数またはジェネリック メソッド定義の型パラメータを表す Type オブジェクトの配列。現在のメソッドがジェネリック メソッドでない場合は空の配列を返します。

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

ジェネリック メソッドの型引数を取得して表示する方法のコード例を次に示します。
このコード例は、MakeGenericMethod メソッドのトピックで取り上げているコード例の一部分です。
' If this is a generic method, display its type arguments. ' If mi.IsGenericMethod Then Dim typeArguments As Type() = mi.GetGenericArguments() Console.WriteLine(vbTab & "List type arguments ({0}):", _ typeArguments.Length) For Each tParam As Type In typeArguments ' IsGenericParameter is true only for generic type ' parameters. ' If tParam.IsGenericParameter Then Console.WriteLine(vbTab & vbTab _ & "{0} parameter position: {1}" _ & vbCrLf & vbTab & vbTab _ & " declaring method: {2}", _ tParam, _ tParam.GenericParameterPosition, _ tParam.DeclaringMethod) Else Console.WriteLine(vbTab & vbTab & tParam.ToString()) End If Next tParam End If
// If this is a generic method, display its type arguments. // if (mi.IsGenericMethod) { Type[] typeArguments = mi.GetGenericArguments(); Console.WriteLine("\tList type arguments ({0}):", typeArguments.Length); foreach (Type tParam in typeArguments) { // IsGenericParameter is true only for generic type // parameters. // if (tParam.IsGenericParameter) { Console.WriteLine("\t\t{0} parameter position {1}" + "\n\t\t declaring method: {2}", tParam, tParam.GenericParameterPosition, tParam.DeclaringMethod); } else { Console.WriteLine("\t\t{0}", tParam); } } }
// If this is a generic method, display its type arguments. // if (mi->IsGenericMethod) { array<Type^>^ typeArguments = mi->GetGenericArguments(); Console::WriteLine("\tList type arguments ({0}):", typeArguments->Length); for each (Type^ tParam in typeArguments) { // IsGenericParameter is true only for generic type // parameters. // if (tParam->IsGenericParameter) { Console::WriteLine("\t\t{0} parameter position {1}" + "\n\t\t declaring method: {2}", tParam, tParam->GenericParameterPosition, tParam->DeclaringMethod); } 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に収録されているすべての辞書からMethodInfo.GetGenericArguments メソッドを検索する場合は、下記のリンクをクリックしてください。

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