Export (0) Print
Expand All
Expand Minimize

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.

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

'Declaration
<SerializableAttribute> _
<FlagsAttribute> _
<ComVisibleAttribute(True)> _
Public Enumeration MemberTypes

Member nameDescription
Supported by the XNA FrameworkSupported by Portable Class LibraryConstructorSpecifies that the member is a constructor, representing a ConstructorInfo member. Hexadecimal value of 0x01.
Supported by the XNA FrameworkSupported by Portable Class LibraryEventSpecifies that the member is an event, representing an EventInfo member. Hexadecimal value of 0x02.
Supported by the XNA FrameworkSupported by Portable Class LibraryFieldSpecifies that the member is a field, representing a FieldInfo member. Hexadecimal value of 0x04.
Supported by the XNA FrameworkSupported by Portable Class LibraryMethodSpecifies that the member is a method, representing a MethodInfo member. Hexadecimal value of 0x08.
Supported by the XNA FrameworkSupported by Portable Class LibraryPropertySpecifies that the member is a property, representing a PropertyInfo member. Hexadecimal value of 0x10.
Supported by the XNA FrameworkSupported by Portable Class LibraryTypeInfoSpecifies that the member is a type, representing a TypeInfo member. Hexadecimal value of 0x20.
Supported by the XNA FrameworkSupported by Portable Class LibraryCustomSpecifies that the member is a custom member type. Hexadecimal value of 0x40.
Supported by the XNA FrameworkSupported by Portable Class LibraryNestedTypeSpecifies that the member is a nested type, extending MemberInfo.
Supported by the XNA FrameworkSupported by Portable Class LibraryAllSpecifies 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.


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


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2014 Microsoft