[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
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)
| Member name | Description | |
|---|---|---|
|
Constructor | Specifies that the member is a constructor, representing a ConstructorInfo member. Hexadecimal value of 0x01. |
|
Event | Specifies that the member is an event, representing an EventInfo member. Hexadecimal value of 0x02. |
|
Field | Specifies that the member is a field, representing a FieldInfo member. Hexadecimal value of 0x04. |
|
Method | Specifies that the member is a method, representing a MethodInfo member. Hexadecimal value of 0x08. |
|
Property | Specifies that the member is a property, representing a PropertyInfo member. Hexadecimal value of 0x10. |
|
TypeInfo | Specifies that the member is a type, representing a TypeInfo member. Hexadecimal value of 0x20. |
|
Custom | Specifies that the member is a custom member type. Hexadecimal value of 0x40. |
|
NestedType | Specifies that the member is a nested type, extending MemberInfo. |
|
All | Specifies all member types. |
These enum values are returned by MemberType and are useful in switch statements. MemberTypes matches CorTypeAttr as defined in the corhdr.h file.
To obtain the MemberTypes value for a method:
-
First get a Type.
-
From the Type, get the MemberInfo array.
-
From the MemberInfo array, get the MemberType.
The following example displays the member types for the specified class.
using System; using System.Reflection; class membertypesenum { public static int Main(string[] args) { Console.WriteLine ("\nReflection.MemberTypes"); MemberTypes Mymembertypes; // Get the type of a chosen class. Type Mytype = Type.GetType ("System.Reflection.ReflectionTypeLoadException"); // Get the MemberInfo array. MemberInfo[] Mymembersinfoarray = Mytype.GetMembers(); // Get and display the name and the MemberType for each member. foreach (MemberInfo Mymemberinfo in Mymembersinfoarray) { Mymembertypes = Mymemberinfo.MemberType; Console.WriteLine("The member {0} of {1} is a {2}.", Mymemberinfo.Name, Mytype, Mymembertypes.ToString()); } return 0; } }
Windows 8 Release Preview, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 SP2, Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

