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 the Type of property reflected by this PropertyInfo object.

[Visual Basic]
Overrides Public ReadOnly Property MemberType As MemberTypes
[C#]
public override MemberTypes MemberType {get;}
[C++]
public: __property MemberTypes get_MemberType();
[JScript]
public override function get MemberType() : MemberTypes;

Property Value

A MemberTypes object representing the type of the property.

Remarks

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.

Example

The following example displays the type of the specified member.

[Visual Basic] 
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

[C#] 
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;
    }
}

[C++] 
#using <mscorlib.dll>
using namespace System;
using namespace System::Reflection;

int main()
{
    Console::WriteLine(S"\nReflection.PropertyInfo");

    // Get the type and PropertyInfo.
    Type* MyType = Type::GetType(S"System.Reflection.MemberInfo");
    PropertyInfo* Mypropertyinfo = MyType->GetProperty(S"Name");

    // Read and display the MemberType property.
    Console::Write(S"\nMemberType = {0}", __box(Mypropertyinfo->MemberType));

    return 0;
}

[JScript] 
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
*/

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

PropertyInfo Class | PropertyInfo Members | System.Reflection Namespace

Show:
© 2014 Microsoft