MemberTypes Enumeration
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.
[Visual Basic] <Flags> <Serializable> Public Enum MemberTypes [C#] [Flags] [Serializable] public enum MemberTypes [C++] [Flags] [Serializable] __value public enum MemberTypes [JScript] public Flags Serializable enum MemberTypes
Remarks
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.
Members
| Member name | Description | Value |
|---|---|---|
| All Supported by the .NET Compact Framework. | Specifies all member types. | 191 |
| Constructor Supported by the .NET Compact Framework. | Specifies that the member is a constructor, representing a ConstructorInfo member. Hexadecimal value of 0x01. | 1 |
| Custom Supported by the .NET Compact Framework. | Specifies that the member is a custom member type. Hexadecimal value of 0x40. | 64 |
| Event Supported by the .NET Compact Framework. | Specifies that the member is an event, representing an EventInfo member. Hexadecimal value of 0x02. | 2 |
| Field Supported by the .NET Compact Framework. | Specifies that the member is a field, representing a FieldInfo member. Hexadecimal value of 0x04. | 4 |
| Method Supported by the .NET Compact Framework. | Specifies that the member is a method, representing a MethodInfo member. Hexadecimal value of 0x08. | 8 |
| NestedType Supported by the .NET Compact Framework. | Specifies that the member is a nested type, extending MemberInfo. | 128 |
| Property Supported by the .NET Compact Framework. | Specifies that the member is a property, representing a PropertyInfo member. Hexadecimal value of 0x10. | 16 |
| TypeInfo Supported by the .NET Compact Framework. | Specifies that the member is a type, representing a TypeInfo member. Hexadecimal value of 0x20. | 32 |
Example
[Visual Basic, C#, C++] The following example displays the member types for the specified class.
[Visual Basic] Imports System Imports System.Reflection Imports Microsoft.VisualBasic Class membertypesenum Public Overloads Shared Function Main(ByVal args() As String) As Integer Console.WriteLine(ControlChars.Lf & "Reflection.MemberTypes") Dim Mymembertypes As MemberTypes ' Get the type of a chosen class. Dim Mytype As Type = Type.GetType("System.Reflection.ReflectionTypeLoadException") ' Get the MemberInfo array. Dim Mymembersinfoarray As MemberInfo() = Mytype.GetMembers() ' Get and display the name and the MemberType for each member. Dim Mymemberinfo As MemberInfo For Each Mymemberinfo In Mymembersinfoarray Mymembertypes = Mymemberinfo.MemberType Console.WriteLine("The member {0} of {1} is a {2}.", Mymemberinfo.Name, Mytype, Mymembertypes.ToString()) Next Mymemberinfo Return 0 End Function 'Main End Class 'membertypesenum [C#] 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; } } [C++] #using <mscorlib.dll> using namespace System; using namespace System::Reflection; int main() { Console::WriteLine (S"\nReflection.MemberTypes"); MemberTypes Mymembertypes; // Get the type of a chosen class. Type* Mytype = Type::GetType (S"System.Reflection.ReflectionTypeLoadException"); // Get the MemberInfo array. MemberInfo* Mymembersinfoarray[] = Mytype->GetMembers(); // Get and display the name and the MemberType for each member. System::Collections::IEnumerator* enum0 = Mymembersinfoarray->GetEnumerator(); while (enum0->MoveNext()) { MemberInfo* Mymemberinfo = __try_cast<MemberInfo*>(enum0->Current); Mymembertypes = Mymemberinfo->MemberType; Console::WriteLine(S"The member {0} of {1} is a {2}.", Mymemberinfo->Name, Mytype, __box(Mymembertypes)); } return 0; }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System.Reflection
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
Assembly: Mscorlib (in Mscorlib.dll)