PropertyInfo.MemberType Właściwość

Definicja

Pobiera wartość wskazującą MemberTypes , że ten element członkowski jest właściwością.

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

Wartość właściwości

MemberTypes

Wartość MemberTypes wskazująca, że ten element członkowski jest właściwością.

Implementuje

Przykłady

Poniższy przykład przedstawia typ określonego elementu członkowskiego.

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

Uwagi

Ta właściwość zastępuje MemberType. W związku z tym podczas badania zestawu MemberInfo obiektów , na przykład tablicy zwróconej przez GetMembers , MemberType właściwość zwraca Property tylko wtedy, gdy dany element członkowski jest właściwością.

MemberType jest klasą pochodną i MemberInfo określa typ składowej. Typy składowe to konstruktory, właściwości, pola i metody. Ponieważ jest to właściwość, zwracany typ jest PropertyInfo właściwością.

Aby uzyskać właściwość, najpierw pobierz klasę MemberType Type. W pliku Typepobierz element PropertyInfo. Z elementu PropertyInfopobierz MemberType wartość .

Dotyczy