MemberType Property

MemberInfo.MemberType Property

When overridden in a derived class, gets a MemberTypes value indicating the type of the member — method, constructor, event, and so on.

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

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

public abstract function get MemberType () : MemberTypes

Not applicable.

Property Value

A MemberTypes value indicating the type of member.

This property is overridden in derived classes, and the override returns the appropriate member type. Therefore, when you examine a set of MemberInfo objects — for example, the array returned by GetMembers — the MemberType property can be used to determine the member type of any given member.

To get the MemberType property, get the class Type. From the Type, get the MethodInfo array. From the MethodInfo array, get the MemberTypes.

The following example displays the member name and type of a specified class.

using System;
using System.Reflection;
 
class Mymemberinfo
{
    public static int Main()
    {
        Console.WriteLine ("\nReflection.MemberInfo");
       
        // Get the Type and MemberInfo.
        Type MyType = Type.GetType("System.Reflection.PropertyInfo");
        MemberInfo[] Mymemberinfoarray = MyType.GetMembers();
  
        // Get the MemberType method and display the elements.
        Console.Write("\nThere are {0} members in ", Mymemberinfoarray.GetLength(0));
        Console.Write("{0}.", MyType.FullName);
  
        for (int counter = 0; counter < Mymemberinfoarray.Length; counter++)
        {
            Console.Write("\n" + counter + ". " 
                + Mymemberinfoarray[counter].Name
                + " Member type - " +
                Mymemberinfoarray[counter].MemberType.ToString());
        }
        return 0;
    }
}


import System.*;
import System.Reflection.*;

class MyMemberInfo
{
    public static void main(String[] args)
    {
        Console.WriteLine("\nReflection.MemberInfo");

        // Get the Type and MemberInfo.
        Type myType = Type.GetType("System.Reflection.PropertyInfo");
        MemberInfo myMemberInfoArray[] = myType.GetMembers();

        // Get the MemberType method and display the elements.
        Console.Write("\nThere are {0} members in ",
            String.valueOf(myMemberInfoArray.GetLength(0)));
        Console.Write("{0}.", myType.get_FullName());

        for (int counter=0; counter < myMemberInfoArray.length; counter++) {
            Console.Write(("\n" + counter + ". " 
                + myMemberInfoArray[counter].get_Name() + " Member type - "
                + myMemberInfoArray[counter].get_MemberType().toString()));
        } 
    } //main
} //MyMemberInfo

import System;
import System.Reflection;
 
 class Mymemberinfo
 {
    public static function Main() : void
    {
       Console.WriteLine ("\nReflection.MemberInfo");
       
       //Get the Type and MemberInfo.
       var MyType : Type = Type.GetType("System.Reflection.PropertyInfo");
       var Mymemberinfoarray : MemberInfo[] = MyType.GetMembers();
  
       //Get the MemberType method and display the elements.
       Console.Write("\nThere are {0} members in ",
          Mymemberinfoarray.GetLength(0));
       Console.Write("{0}.", MyType.FullName);
  
       for (var counter : int in Mymemberinfoarray)
       {
          Console.Write("\n" + counter + ". " 
             + Mymemberinfoarray[counter].Name
             + " Member type - " +
             Mymemberinfoarray[counter].MemberType.ToString());
       }
    }
 }
 Mymemberinfo.Main();

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

ADD
Show:
© 2016 Microsoft