System.Reflection.Emit.ModuleBuilder.DefineEnum Method

Defines an enumeration type that is a value type with a single non-static field called value__ of the specified type.

Syntax

public EnumBuilder DefineEnum (string name, System.Reflection.TypeAttributes visibility, Type underlyingType)

Parameters

name
The full path of the enumeration type. name cannot contain embedded nulls.
visibility
The type attributes for the enumeration. The attributes are any bits defined by System.Reflection.TypeAttributes.VisibilityMask.
underlyingType
The underlying type for the enumeration. This must be a built-in integer type.

Returns

The defined enumeration.

Remarks

The defined enum is a derived class of Enum. The value__ field has System.Reflection.FieldAttributes.Private and System.Reflection.FieldAttributes.SpecialName attributes set.

For more information about the built-in integer types that can be specified as the underlying types of enumerations, see .NET Framework Class Library Overview.

Note:

In the .NET Framework versions 1.0 and 1.1, it is necessary to define enumerations using System.Reflection.Emit.TypeBuilder because System.Reflection.Emit.EnumBuilder emits enumerations whose elements are of type int instead of the enumeration type. In the .NET Framework version 2.0, System.Reflection.Emit.EnumBuilder emits enumerations whose elements have the correct type.

Note:

Starting with the net_v20sp1_long, this member no longer requires System.Security.Permissions.ReflectionPermission with the System.Security.Permissions.ReflectionPermissionFlag.ReflectionEmit flag. (See Security Issues in Reflection Emit.) To use this functionality, your application should target the net_v35_long or later.

Requirements

Namespace: System.Reflection.Emit
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0