PropertyInfo.MemberType 属性   
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取一个 MemberTypes 值,该值指示此成员是属性。
public:
 virtual property System::Reflection::MemberTypes MemberType { System::Reflection::MemberTypes get(); };public override System.Reflection.MemberTypes MemberType { get; }member this.MemberType : System.Reflection.MemberTypesPublic Overrides ReadOnly Property MemberType As MemberTypes属性值
指示此成员是属性的一个 MemberTypes 值。
实现
示例
以下示例显示指定成员的类型。
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
注解
此属性替代 MemberType。 因此,在检查一组 MemberInfo 对象(例如,返回 GetMembers 的数组)时,仅当给定成员为属性时, MemberType 属性才会返回 Property 。
              MemberType 是 的 MemberInfo 派生类,并指定此成员的类型。 成员类型是构造函数、属性、字段和方法。 由于这是一个 PropertyInfo 属性,因此返回的类型是属性。
若要获取 MemberType 属性,请首先获取 类 Type。 从 中 Type获取 PropertyInfo。 从 中 PropertyInfo获取 MemberType 值。