MemberTypes Enumeração

Definição

Marca cada tipo de membro que é definido como uma classe derivada de MemberInfo.Marks each type of member that is defined as a derived class of MemberInfo.

Esta enumeração tem um atributo FlagsAttribute que permite uma combinação bit a bit dos seus valores membros.

public enum class MemberTypes
[System.Flags]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public enum MemberTypes
type MemberTypes = 
Public Enum MemberTypes
Herança
MemberTypes
Atributos

Campos

All 191

Especifica todos os tipos de membro.Specifies all member types.

Constructor 1

Especifica que o membro é um construtor.Specifies that the member is a constructor.

Custom 64

Especifica que o membro é um tipo de membro personalizado.Specifies that the member is a custom member type.

Event 2

Especifica que o membro é um evento.Specifies that the member is an event.

Field 4

Especifica que o membro é um campo.Specifies that the member is a field.

Method 8

Especifica que o membro é um método.Specifies that the member is a method.

NestedType 128

Especifica que o membro é um tipo aninhado.Specifies that the member is a nested type.

Property 16

Especifica que o membro é uma propriedade.Specifies that the member is a property.

TypeInfo 32

Especifica que o membro é um tipo.Specifies that the member is a type.

Exemplos

O exemplo a seguir exibe os nomes dos membros da classe ReflectionTypeLoadException e seus tipos de membro associados.The following example displays the names of the members of the ReflectionTypeLoadException class and their associated member types.

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

Comentários

Esses valores de enumeração são retornados pelas seguintes propriedades:These enumeration values are returned by the following properties:

Para obter o valor de MemberTypes para um tipo:To obtain the MemberTypes value for a type:

  1. Obtenha um objeto Type que representa esse tipo.Get a Type object that represents that type.

  2. Recupere o valor da propriedade Type.MemberType.Retrieve the value of the Type.MemberType property.

Para obter os valores de MemberTypes para os membros de um tipo.:To get the MemberTypes values for the members of a type.:

  1. Obtenha um objeto Type que representa esse tipo.Get a Type object that represents that type.

  2. Recupere a matriz MemberInfo que representa os membros desse tipo chamando o método Type.GetMembers.Retrieve the MemberInfo array that represents the members of that type by calling the Type.GetMembers method.

  3. Recupere o valor do da propriedade MemberInfo.MemberType para cada membro na matriz.Retrieve the value of the From the MemberInfo.MemberType property for each member in the array. Uma instrução switch na C# instrução ou Select Case em Visual Basic normalmente é usada para processar tipos de membro.A switch statement in C# or Select Case statement in Visual Basic is typically used to process member types.

MemberTypes corresponde a CorTypeAttr conforme definido no arquivo corhdr. h.MemberTypes matches CorTypeAttr as defined in the corhdr.h file.

Aplica-se a