_MethodInfo.MemberType プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > _MethodInfo.MemberType プロパティの意味・解説 

_MethodInfo.MemberType プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

COM オブジェクトに、MemberType プロパティへのバージョン依存しないアクセス用意されています。

このプロパティは、CLS準拠していません。  

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

ReadOnly Property MemberType As
 MemberTypes
Dim instance As _MethodInfo
Dim value As MemberTypes

value = instance.MemberType
MemberTypes MemberType { get; }
property MemberTypes MemberType {
    MemberTypes get ();
}
/** @property */
MemberTypes get_MemberType ()
function get MemberType () : MemberTypes

プロパティ
メンバの型を示す MemberTypes 値の 1 つ

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
_MethodInfo インターフェイス
_MethodInfo メンバ
System.Runtime.InteropServices 名前空間

MethodInfo.MemberType プロパティ

このメンバメソッドであることを示す MemberTypes 値を取得します

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

Public Overrides ReadOnly
 Property MemberType As MemberTypes
Dim instance As MethodInfo
Dim value As MemberTypes

value = instance.MemberType
public override MemberTypes MemberType { get;
 }
public:
virtual property MemberTypes MemberType {
    MemberTypes get () override;
}
/** @property */
public MemberTypes get_MemberType ()
public override function get
 MemberType () : MemberTypes

プロパティ
このメンバメソッドであることを示す MemberTypes 値。

解説解説

このプロパティは MemberInfo.MemberType をオーバーライドます。たがって、MemberInfo オブジェクトセット (GetMembers によって返され配列など) を調べた場合指定したメンバメソッドである場合のみ、MemberType プロパティは MemberTypes.Method を返します

MemberType プロパティ取得するには、最初に Type クラス取得します。そして、その Type から MethodInfo取得します。そして、その MethodInfo から MemberType取得します

使用例使用例

指定したメンバの型を表示する例を次に示します

Imports System
Imports System.Reflection

Class MyMethodInfo

    Public Shared Function
 Main() As Integer
        Console.WriteLine("Reflection.MethodInfo")

        ' Get the Type and MethodInfo.
        Dim MyType As Type = Type.GetType("System.Reflection.FieldInfo")
        Dim Mymethodinfo As MethodInfo = MyType.GetMethod("GetValue")
        Console.WriteLine(MyType.FullName + "." +
 Mymethodinfo.Name)

        ' Get and display the MemberType property.
        Dim Mymembertypes As MemberTypes =
 Mymethodinfo.MemberType

        If MemberTypes.Constructor = Mymembertypes Then
            Console.WriteLine("MemberType is of type All.")

        ElseIf MemberTypes.Custom = Mymembertypes Then
            Console.WriteLine("MemberType is of type Custom.")

        ElseIf MemberTypes.Event = Mymembertypes Then
            Console.WriteLine("MemberType is of type Event.")

        ElseIf MemberTypes.Field = Mymembertypes Then
            Console.WriteLine("MemberType is of type Field.")

        ElseIf MemberTypes.Method = Mymembertypes Then
            Console.WriteLine("MemberType is of type Method.")

        ElseIf MemberTypes.Property = Mymembertypes Then
            Console.WriteLine("MemberType is of type Property.")

        ElseIf MemberTypes.TypeInfo = Mymembertypes Then
            Console.WriteLine("MemberType is of type TypeInfo.")

        End If
        Return 0
    End Function
End Class
using System;
using System.Reflection;
 
class MyMethodInfo
{
    public static int Main()
    {
        Console.WriteLine("Reflection.MethodInfo");
  
        // Get the Type and MethodInfo.
        Type MyType = Type.GetType("System.Reflection.FieldInfo");
        MethodInfo Mymethodinfo = MyType.GetMethod("GetValue");
        Console.WriteLine(MyType.FullName + "." + Mymethodinfo.Name);
  
        // Get and display the MemberType property.
        MemberTypes Mymembertypes = Mymethodinfo.MemberType;
      
 
        if (MemberTypes.Constructor == Mymembertypes)
        {
            Console.WriteLine("MemberType is of type All.");
        }
        else if (MemberTypes.Custom == Mymembertypes)
        {
            Console.WriteLine("MemberType is of type Custom.");
        }
        else if (MemberTypes.Event == Mymembertypes)
        {
            Console.WriteLine("MemberType is of type Event.");
        }
        else if (MemberTypes.Field == Mymembertypes)
        {
            Console.WriteLine("MemberType is of type Field.");
        }
        else if (MemberTypes.Method == Mymembertypes)
        {
            Console.WriteLine("MemberType is of type Method.");
        }
        else if (MemberTypes.Property == Mymembertypes)
        {
            Console.WriteLine("MemberType is of type Property.");
        }
        else if (MemberTypes.TypeInfo == Mymembertypes)
        {
            Console.WriteLine("MemberType is of type TypeInfo.");
        }
 
        return 0;
    }
}
using namespace System;
using namespace System::Reflection;
int main()
{
   Console::WriteLine( "Reflection.MethodInfo" );
   
   // Get the Type and MethodInfo.
   Type^ MyType = Type::GetType( "System.Reflection.FieldInfo" );
   MethodInfo^ Mymethodinfo = MyType->GetMethod( "GetValue" );
   Console::WriteLine( "{0}.{1}", MyType->FullName, Mymethodinfo->Name
 );
   
   // Get and display the MemberType property.
   MemberTypes Mymembertypes = Mymethodinfo->MemberType;
   if ( MemberTypes::Constructor == Mymembertypes )
   {
      Console::WriteLine( "MemberType is of type All." );
   }
   else
   if ( MemberTypes::Custom == Mymembertypes )
   {
      Console::WriteLine( "MemberType is of type Custom." );
   }
   else
   if ( MemberTypes::Event == Mymembertypes )
   {
      Console::WriteLine( "MemberType is of type Event." );
   }
   else
   if ( MemberTypes::Field == Mymembertypes )
   {
      Console::WriteLine( "MemberType is of type Field." );
   }
   else
   if ( MemberTypes::Method == Mymembertypes )
   {
      Console::WriteLine( "MemberType is of type Method." );
   }
   else
   if ( MemberTypes::Property == Mymembertypes )
   {
      Console::WriteLine( "MemberType is of type Property." );
   }
   else
   if ( MemberTypes::TypeInfo == Mymembertypes )
   {
      Console::WriteLine( "MemberType is of type TypeInfo." );
   }







   return 0;
}

import System.*;
import System.Reflection.*;

class MyMethodInfo
{
    public static void main(String[]
 args)
    {
        Console.WriteLine("Reflection.MethodInfo");

        // Get the Type and MethodInfo.
        Type myType = Type.GetType("System.Reflection.FieldInfo");
        MethodInfo myMethodInfo = myType.GetMethod("GetValue");

        Console.WriteLine((myType.get_FullName() + "." 
            + myMethodInfo.get_Name()));

        // Get and display the MemberType property.
        MemberTypes myMemberTypes = myMethodInfo.get_MemberType();

        if (MemberTypes.Constructor.Equals(myMemberTypes)) {
            Console.WriteLine("MemberType is of type All.");
        }
        else {
            if (MemberTypes.Custom.Equals(myMemberTypes)) {
                Console.WriteLine("MemberType is of type Custom.");
            }
            else {
                if ( MemberTypes.Event.Equals(myMemberTypes))
 {
                    Console.WriteLine("MemberType is of type Event.");
                }
                else {
                    if ( MemberTypes.Field.Equals(myMemberTypes))
 {
                        Console.WriteLine("MemberType is of type Field.");
                    }
                    else {
                        if ( MemberTypes.Method.Equals(myMemberTypes))
 {
                            Console.WriteLine("MemberType is of type Method.");
                        }
                        else {
                            if ( MemberTypes.Property.Equals(myMemberTypes))
 {
                                Console.WriteLine(
                                    "MemberType is of type Property.");
                            }
                            else {
                                if ( MemberTypes.TypeInfo.Equals
                                    (myMemberTypes)) {
                                    Console.WriteLine
                                        ("MemberType is of type TypeInfo.");
                                }
                            }
                        } 
                    }
                }
            }
        }
    } //main
} //MyMethodInfo
import System;
import System.Reflection;
 
 class MyMethodInfo
 {
   public static function
 Main() : void
   {
       Console.WriteLine("Reflection.MethodInfo");
  
       //Get the Type and MethodInfo.
       var MyType : Type = Type.GetType("System.Reflection.FieldInfo");
       var Mymethodinfo : MethodInfo = MyType.GetMethod("GetValue");
       Console.WriteLine(MyType.FullName + "." + Mymethodinfo.Name);
  
       //Get and display the MemberType property.
       var Mymembertypes : MemberTypes = Mymethodinfo.MemberType;
      
 
       if ( MemberTypes.Constructor == Mymembertypes )
       {
          Console.WriteLine( "MemberType is of type All" );
       }
       else if ( MemberTypes.Custom == Mymembertypes
 )
       {
          Console.WriteLine( "MemberType is of type Custom" );
       }
       else if ( MemberTypes.Event == Mymembertypes
 )
       {
          Console.WriteLine( "MemberType is of type Event" );
       }
       else if ( MemberTypes.Field == Mymembertypes
 )
       {
          Console.WriteLine( "MemberType is of type Field" );
       }
       else if ( MemberTypes.Method == Mymembertypes
 )
       {
          Console.WriteLine( "MemberType is of type Method" );
       }
       else if ( MemberTypes.Property == Mymembertypes
 )
       {
          Console.WriteLine( "MemberType is of type Property" );
       }
       else if ( MemberTypes.TypeInfo == Mymembertypes
 )
       {
          Console.WriteLine( "MemberType is of type TypeInfo" );
       }
 
    }
 }
 MyMethodInfo.Main();
 /*
 This code produces the following output:
 
 Reflection.MethodInfo
 System.Reflection.FieldInfo.GetValue
 MemberType is of type Method
 */
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

_MethodInfo.MemberType プロパティのお隣キーワード
検索ランキング

   

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



_MethodInfo.MemberType プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS