PropertyInfo.MemberType Свойство

Определение

MemberTypes Возвращает значение, указывающее, что этот элемент является свойством.

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

Значение свойства

MemberTypes Значение, указывающее, что этот элемент является свойством.

Реализации

Примеры

В следующем примере отображается тип указанного элемента.

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

Комментарии

Это свойство переопределяет MemberType. Таким образом, при проверке набора MemberInfo объектов , например, массив, возвращаемый GetMembers свойством, MemberType возвращается Property только в том случае, если данный элемент является свойством.

MemberType является производным классом MemberInfo и указывает тип элемента. Типы элементов — это конструкторы, свойства, поля и методы. Так как это PropertyInfo свойство, возвращаемый тип является свойством.

Чтобы получить MemberType свойство, сначала получите класс Type. Из файла Typeполучите PropertyInfo. В поле PropertyInfoMemberTypeполучите значение.

Применяется к