PropertyInfo.MemberType Propriedade

Definição

Obtém um valor MemberTypes que indica que este membro é uma propriedade.Gets a MemberTypes value indicating that this member is a property.

public:
 virtual property System::Reflection::MemberTypes MemberType { System::Reflection::MemberTypes get(); };
public override System.Reflection.MemberTypes MemberType { get; }
member this.MemberType : System.Reflection.MemberTypes
Public Overrides ReadOnly Property MemberType As MemberTypes

Valor da propriedade

Um valor MemberTypes que indica que este membro é uma propriedade.A MemberTypes value indicating that this member is a property.

Implementações

Exemplos

O exemplo a seguir exibe o tipo do membro especificado.The following example displays the type of the specified member.

using namespace System;
using namespace System::Reflection;
int main()
{
   Console::WriteLine( "\nReflection.PropertyInfo" );
   
   // Get the type and PropertyInfo.
   Type^ MyType = Type::GetType( "System.Reflection.MemberInfo" );
   PropertyInfo^ Mypropertyinfo = MyType->GetProperty( "Name" );
   
   // Read and display the MemberType property.
   Console::Write( "\nMemberType = {0}", Mypropertyinfo->MemberType );
   return 0;
}

using System;
using System.Reflection;
 
class Mypropertyinfo
{
    public static int Main()
    {
        Console.WriteLine("\nReflection.PropertyInfo");
  
        // Get the type and PropertyInfo.
        Type MyType = Type.GetType("System.Reflection.MemberInfo");
        PropertyInfo Mypropertyinfo = MyType.GetProperty("Name");
  
        // Read and display the MemberType property.
        Console.Write("\nMemberType = " + Mypropertyinfo.MemberType.ToString());
  
        return 0;
    }
}
Imports System.Reflection

Class Mypropertyinfo

    Public Shared Function Main() As Integer
        Console.WriteLine(ControlChars.CrLf & "Reflection.PropertyInfo")

        ' Get the type and PropertyInfo.
        Dim MyType As Type = Type.GetType("System.Reflection.MemberInfo")
        Dim Mypropertyinfo As PropertyInfo = MyType.GetProperty("Name")

        ' Read and display the MemberType property.
        Console.WriteLine("MemberType = " & _
           Mypropertyinfo.MemberType.ToString())

        Return 0
    End Function
End Class

Comentários

Esta propriedade substitui MemberType.This property overrides MemberType. Portanto, quando você examina um conjunto de MemberInfo objetos – por exemplo, a matriz retornada por GetMembers -a MemberType propriedade retorna Property somente quando um determinado membro é uma propriedade.Therefore, when you examine a set of MemberInfo objects - for example, the array returned by GetMembers - the MemberType property returns Property only when a given member is a property.

MemberTypeé uma classe derivada de MemberInfo e especifica o tipo de membro que é.MemberType is a derived class of MemberInfo and specifies the type of member this is. Os tipos de membro são construtores, propriedades, campos e métodos.Member types are constructors, properties, fields, and methods. Como essa é uma PropertyInfo Propriedade, o tipo retornado é uma propriedade.Since this is a PropertyInfo property, the returned type is a property.

Para obter a MemberType Propriedade, primeiro obtenha a classe Type.To get the MemberType property, first get the class Type. No, obtenha o PropertyInfo. TypeFrom the Type, get the PropertyInfo. No, obtenha o MemberType valor. PropertyInfoFrom the PropertyInfo, get the MemberType value.

Aplica-se a