Type.IsGenericParameter プロパティ
アセンブリ: mscorlib (mscorlib.dll 内)


ジェネリック型パラメータを表す Type オブジェクトを取得するには、ジェネリック型定義を表すType オブジェクトの GetGenericArguments メソッドを呼び出すか、またはジェネリック メソッド定義を表す MethodInfo オブジェクトの GetGenericArguments メソッドを呼び出します。
-
ジェネリック型定義またはジェネリック メソッド定義の場合、IsGenericParameter プロパティは結果の配列の各要素に対して true を返します。
-
クローズ構築型またはメソッドの場合、IsGenericParameter プロパティは GetGenericArguments メソッドによって返される配列の各要素に対して false を返します。
-
オープン構築型またはメソッドの場合は、配列のいくつかの要素が固有の型となり、他の要素が型パラメータとなる場合があります。IsGenericParameter は、型に対して false を返し、型パラメータに対して true を返します。さまざまな型および型パラメータが混在して指定されたジェネリック クラスを ContainsGenericParameters プロパティのコード例に示します。
ジェネリック リフレクションで使用される用語の一定の条件の一覧については、IsGenericType のプロパティの解説を参照してください。

IsGenericParameter プロパティを使用してジェネリック型のジェネリック型パラメータをテストする例を次に示します。
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.IsGenericParameter プロパティを検索する場合は、下記のリンクをクリックしてください。

- Type.IsGenericParameter プロパティのページへのリンク