Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Marks each type of member that is defined as a derived class of MemberInfo.
This enumeration supports a bitwise combination of its member values.
public enum class MemberTypes
[System.Flags]
public enum MemberTypes
[System.Flags]
[System.Serializable]
public enum MemberTypes
[System.Flags]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum MemberTypes
[<System.Flags>]
type MemberTypes =
[<System.Flags>]
[<System.Serializable>]
type MemberTypes =
[<System.Flags>]
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type MemberTypes =
Public Enum MemberTypes
Name | Value | Description |
---|---|---|
Constructor | 1 | Specifies that the member is a constructor. |
Event | 2 | Specifies that the member is an event. |
Field | 4 | Specifies that the member is a field. |
Method | 8 | Specifies that the member is a method. |
Property | 16 | Specifies that the member is a property. |
TypeInfo | 32 | Specifies that the member is a type. |
Custom | 64 | Specifies that the member is a custom member type. |
NestedType | 128 | Specifies that the member is a nested type. |
All | 191 | Specifies all member types. |
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
Imports System.Reflection
Module Example
Public Sub Main()
' Get the type of a particular class.
Dim t As Type = GetType(ReflectionTypeLoadException)
' Get the MemberInfo array.
Dim members As MemberInfo() = t.GetMembers()
' Get and display the name and the MemberType for each member.
Console.WriteLine("Members of {0}", t.Name)
For Each member In members
Dim memberType As MemberTypes = member.MemberType
Console.WriteLine(" {0}: {1}", member.Name, memberType)
Next
End Sub
End Module
' 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
These enumeration values are returned by the following properties:
To obtain the MemberTypes value for a type:
Get a Type object that represents that type.
Retrieve the value of the Type.MemberType property.
To get the MemberTypes values for the members of a type.:
Get a Type object that represents that type.
Retrieve the MemberInfo array that represents the members of that type by calling the Type.GetMembers method.
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.
Product | Versions |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.5, 1.6, 2.0, 2.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in