Type.GetGenericArguments メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > Type.GetGenericArguments メソッドの意味・解説 

Type.GetGenericArguments メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

ジェネリック型型引数またはジェネリック型定義型パラメータを表す Type オブジェクト配列返します

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Overridable Function
 GetGenericArguments As Type()
Dim instance As Type
Dim returnValue As Type()

returnValue = instance.GetGenericArguments
public virtual Type[] GetGenericArguments ()
public:
virtual array<Type^>^ GetGenericArguments ()
public Type[] GetGenericArguments ()
public function GetGenericArguments () : Type[]

戻り値
ジェネリック型型引数を表す Type オブジェクト現在の型がジェネリック型ない場合は空の配列返します

解説解説
使用例使用例

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);
        }
    }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からType.GetGenericArguments メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からType.GetGenericArguments メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からType.GetGenericArguments メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Type.GetGenericArguments メソッド」の関連用語

Type.GetGenericArguments メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Type.GetGenericArguments メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS