PropertyInfo.MemberType 属性

获取一个 MemberTypes 值,该值指示此成员是属性 (Property)。

**命名空间:**System.Reflection
**程序集:**mscorlib(在 mscorlib.dll 中)

语法

声明
Public Overrides ReadOnly Property MemberType As MemberTypes
用法
Dim instance As PropertyInfo
Dim value As MemberTypes

value = instance.MemberType
public override MemberTypes MemberType { get; }
public:
virtual property MemberTypes MemberType {
    MemberTypes get () override;
}
/** @property */
public MemberTypes get_MemberType ()
public override function get MemberType () : MemberTypes

属性值

指示此成员是属性 (Property) 的 MemberTypes 值。

备注

此属性重写 MemberType。因此,如果检查一组 MemberInfo 对象(如 GetMembers 返回的数组),MemberType 属性 (Property) 只在给定成员为属性 (Property) 时才会返回 Property

MemberTypeMemberInfo 的派生类,指定这是成员的类型。成员类型是构造函数、属性 (Property)、字段和方法。因为这是 PropertyInfo 属性 (Property),所以返回类型是属性 (Property)。

若要获取 MemberType 属性,请先获取 Type 类。从 Type 获取 PropertyInfo。从 PropertyInfo 获取 MemberType 值。

示例

下面的示例显示指定成员的类型。

Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic

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
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;
    }
}
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;
}
import System.*;
import System.Reflection.*;

class MyPropertyInfo
{   
    public static void main(String[] args)
    {
        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.get_MemberType().ToString()));
    } //main
} //MyPropertyInfo
import System;
import System.Reflection;

class Mypropertyinfo
{
   public static function Main() : void
   {
      Console.WriteLine("\nReflection.PropertyInfo");
 
      //Get the type and PropertyInfo
      var MyType : Type = Type.GetType("System.Reflection.MemberInfo");
      var Mypropertyinfo : PropertyInfo = MyType.GetProperty("Name");
 
      //Read and display the MemberType property
      Console.Write("\nMemberType = " + Mypropertyinfo.MemberType.ToString());
   }
}
Mypropertyinfo.Main();
/*
Produces the following output

Reflection.PropertyInfo
MemberType = Property
*/

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

PropertyInfo 类
PropertyInfo 成员
System.Reflection 命名空间