MemberTypes 列挙型

定義

MemberInfo の派生クラスとして定義されている各型のメンバーをマークします。

この列挙体は、メンバー値のビットごとの組み合わせをサポートしています。

public enum class MemberTypes
[System.Flags]
public enum MemberTypes
[System.Flags]
[System.Serializable]
public enum MemberTypes
[System.Flags]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum MemberTypes
[<System.Flags>]
type MemberTypes = 
[<System.Flags>]
[<System.Serializable>]
type MemberTypes = 
[<System.Flags>]
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type MemberTypes = 
Public Enum MemberTypes
継承
MemberTypes
属性

フィールド

All 191

すべてのメンバーの型を指定します。

Constructor 1

メンバーがコンストラクターであることを指定します。

Custom 64

メンバーがカスタム メンバー型であることを指定します。

Event 2

メンバーがイベントであることを指定します。

Field 4

メンバーがフィールドであることを指定します。

Method 8

メンバーがメソッドであることを指定します。

NestedType 128

メンバーが入れ子にされた型であることを指定します。

Property 16

メンバーがプロパティであることを指定します。

TypeInfo 32

メンバーが型であることを指定します。

次の例では、 クラスのメンバーの名前と、関連する ReflectionTypeLoadException メンバー型を表示します。

using namespace System;
using namespace System::Reflection;
 
void main() 
{
    // Get the type of a chosen class.
    Type^ t = ReflectionTypeLoadException::typeid;

    // Get the MemberInfo array.
    array<MemberInfo^>^ members = t->GetMembers();

    // Get and display the name and the MemberType for each member.
    Console::WriteLine("Members of {0}", t->Name);
    for each (MemberInfo^ member in members) { 
        MemberTypes memberType = member->MemberType; 
        Console::WriteLine("   {0}: {1}", member->Name, memberType);
    }
}
// The example displays the following output:
//       Members of ReflectionTypeLoadException
//          get_Types: Method
//          get_LoaderExceptions: Method
//          GetObjectData: Method
//          get_Message: Method
//          get_Data: Method
//          GetBaseException: Method
//          get_InnerException: Method
//          get_TargetSite: Method
//          get_StackTrace: Method
//          get_HelpLink: Method
//          set_HelpLink: Method
//          get_Source: Method
//          set_Source: Method
//          ToString: Method
//          get_HResult: Method
//          GetType: Method
//          Equals: Method
//          GetHashCode: Method
//          GetType: Method
//          .ctor: Constructor
//          .ctor: Constructor
//          Types: Property
//          LoaderExceptions: Property
//          Message: Property
//          Data: Property
//          InnerException: Property
//          TargetSite: Property
//          StackTrace: Property
//          HelpLink: Property
//          Source: Property
//          HResult: Property
using System;
using System.Reflection;

class Example
{
    public static void Main()
    {
        // Get the type of a chosen class.
        Type t = typeof(ReflectionTypeLoadException);
 
        // Get the MemberInfo array.
        MemberInfo[] members = t.GetMembers();
 
        // Get and display the name and the MemberType for each member.
        Console.WriteLine("Members of {0}", t.Name);
        foreach (var member in members) { 
            MemberTypes memberType = member.MemberType; 
            Console.WriteLine("   {0}: {1}", member.Name, memberType);
        }
    }
}
// The example displays the following output:
//       Members of ReflectionTypeLoadException
//          get_Types: Method
//          get_LoaderExceptions: Method
//          GetObjectData: Method
//          get_Message: Method
//          get_Data: Method
//          GetBaseException: Method
//          get_InnerException: Method
//          get_TargetSite: Method
//          get_StackTrace: Method
//          get_HelpLink: Method
//          set_HelpLink: Method
//          get_Source: Method
//          set_Source: Method
//          ToString: Method
//          get_HResult: Method
//          GetType: Method
//          Equals: Method
//          GetHashCode: Method
//          GetType: Method
//          .ctor: Constructor
//          .ctor: Constructor
//          Types: Property
//          LoaderExceptions: Property
//          Message: Property
//          Data: Property
//          InnerException: Property
//          TargetSite: Property
//          StackTrace: Property
//          HelpLink: Property
//          Source: Property
//          HResult: Property
Imports System.Reflection

Module Example
    Public Sub Main()
        ' Get the type of a particular class.
        Dim t As Type = GetType(ReflectionTypeLoadException)

        ' Get the MemberInfo array.
        Dim members As MemberInfo() = t.GetMembers()

        ' Get and display the name and the MemberType for each member.
        Console.WriteLine("Members of {0}", t.Name)
        For Each member In members
            Dim memberType As MemberTypes = member.MemberType
            Console.WriteLine("   {0}: {1}", member.Name, memberType)
        Next
    End Sub
End Module
' The example displays the following output:
'       Members of ReflectionTypeLoadException
'          get_Types: Method
'          get_LoaderExceptions: Method
'          GetObjectData: Method
'          get_Message: Method
'          get_Data: Method
'          GetBaseException: Method
'          get_InnerException: Method
'          get_TargetSite: Method
'          get_StackTrace: Method
'          get_HelpLink: Method
'          set_HelpLink: Method
'          get_Source: Method
'          set_Source: Method
'          ToString: Method
'          get_HResult: Method
'          GetType: Method
'          Equals: Method
'          GetHashCode: Method
'          GetType: Method
'          .ctor: Constructor
'          .ctor: Constructor
'          Types: Property
'          LoaderExceptions: Property
'          Message: Property
'          Data: Property
'          InnerException: Property
'          TargetSite: Property
'          StackTrace: Property
'          HelpLink: Property
'          Source: Property
'          HResult: Property

注釈

これらの列挙値は、次のプロパティによって返されます。

型の値を MemberTypes 取得するには:

  1. その型を Type 表す オブジェクトを取得します。

  2. プロパティの値を Type.MemberType 取得します。

型の MemberTypes メンバーの値を取得するには::

  1. その型を Type 表す オブジェクトを取得します。

  2. メソッドを MemberInfo 呼び出して、その型のメンバーを表す配列を Type.GetMembers 取得します。

  3. 配列内の各メンバーの From MemberInfo.MemberType プロパティの値を取得します。 通常、 switch C# の ステートメントまたは Select Case Visual Basic の ステートメントは、メンバー型を処理するために使用されます。

MemberTypes は、corhdr.h ファイルで定義されている CorTypeAttr と一致します。

適用対象