MemberTypes Enumeration


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Marks each type of member that is defined as a derived class of MemberInfo.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

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

public enum MemberTypes

Member nameDescription

Specifies all member types.


Specifies that the member is a constructor


Specifies that the member is a custom member type.


Specifies that the member is an event.


Specifies that the member is a field.


Specifies that the member is a method.


Specifies that the member is a nested type.


Specifies that the member is a property.


Specifies that the member is a type.

These enumeration values are returned by the following properties:

To obtain the MemberTypes value for a type:

  1. Get a Type object that represents that type.

  2. Retrieve the value of the Type.MemberType property.

To get the MemberTypes values for the members of a type.:

  1. Get a Type object that represents that type.

  2. Retrieve the MemberInfo array that represents the members of that type by calling the Type.GetMembers method.

  3. Retrieve the value of the From the MemberInfo.MemberType property for each member in the array. A switch statement in C# or Select Case statement in Visual Basic is typically used to process member types.

MemberTypes matches CorTypeAttr as defined in the corhdr.h file.

The following example displays the names of the members of the ReflectionTypeLoadException class and their associated member types.

using System;
using System.Reflection;

class Example
    public static void Main() 
        // Get the type of a chosen class.
        Type t = typeof(ReflectionTypeLoadException);

        // Get the MemberInfo array.
        MemberInfo[] members = t.GetMembers();

        // Get and display the name and the MemberType for each member.
        Console.WriteLine("Members of {0}", t.Name);
        foreach (var member in members) { 
            MemberTypes memberType = member.MemberType; 
            Console.WriteLine("   {0}: {1}", member.Name, memberType);
// The example displays the following output:
//       Members of ReflectionTypeLoadException
//          get_Types: Method
//          get_LoaderExceptions: Method
//          GetObjectData: Method
//          get_Message: Method
//          get_Data: Method
//          GetBaseException: Method
//          get_InnerException: Method
//          get_TargetSite: Method
//          get_StackTrace: Method
//          get_HelpLink: Method
//          set_HelpLink: Method
//          get_Source: Method
//          set_Source: Method
//          ToString: Method
//          get_HResult: Method
//          GetType: Method
//          Equals: Method
//          GetHashCode: Method
//          GetType: Method
//          .ctor: Constructor
//          .ctor: Constructor
//          Types: Property
//          LoaderExceptions: Property
//          Message: Property
//          Data: Property
//          InnerException: Property
//          TargetSite: Property
//          StackTrace: Property
//          HelpLink: Property
//          Source: Property
//          HResult: Property

.NET Framework
Available since 1.1
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top