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. 배열의 각 멤버에 MemberInfo.MemberType 대한 From 속성 값을 검색합니다. switch C#의 문 또는 Select Case Visual Basic 문은 일반적으로 멤버 형식을 처리하는 데 사용됩니다.

MemberTypes 는 corhdr.h 파일에 정의된 대로 CorTypeAttr과 일치합니다.

적용 대상