Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

PropertyInfo.MemberType Property

Gets a MemberTypes value indicating that this member is a property.

Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)

public override MemberTypes MemberType { get; }
/** @property */
public MemberTypes get_MemberType ()

public override function get MemberType () : MemberTypes

Not applicable.

Property Value

A MemberTypes value indicating that this member is a property.

This property overrides MemberType. 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 is a derived class of MemberInfo and specifies the type of member this is. Member types are constructors, properties, fields, and methods. Since this is a PropertyInfo property, the returned type is a property.

To get the MemberType property, first get the class Type. From the Type, get the PropertyInfo. From the PropertyInfo, get the MemberType value.

The following example displays the type of the specified member.

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;
    }
}

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 Server 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

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0

Community Additions

Show:
© 2014 Microsoft