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

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

MethodInfo.GetGenericArguments メソッド

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

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

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

<ComVisibleAttribute(True)> _
Public Overrides Function
 GetGenericArguments As Type()
Dim instance As MethodInfo
Dim returnValue As Type()

returnValue = instance.GetGenericArguments
[ComVisibleAttribute(true)] 
public override Type[] GetGenericArguments ()
[ComVisibleAttribute(true)] 
public:
virtual array<Type^>^ GetGenericArguments () override
/** @attribute ComVisibleAttribute(true) */ 
public Type[] GetGenericArguments ()
ComVisibleAttribute(true) 
public override function GetGenericArguments
 () : Type[]

戻り値
ジェネリック メソッド型引数またはジェネリック メソッド定義の型パラメータを表す Type オブジェクト配列現在のメソッドジェネリック メソッドない場合は空の配列返します

解説解説

返される配列要素は、ジェネリック メソッド型パラメータリスト内に現れる順番どおりに配置されます。

ジェネリック メソッド固有の用語に関する一定の条件一覧については、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);
        }
    }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

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

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

   

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



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

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

©2024 GRAS Group, Inc.RSS