System.Reflection.Emit.EnumBuilder.DefineLiteral Method

Defines the named static field in an enumeration type with the specified constant value.

Syntax

public FieldBuilder DefineLiteral (string literalName, object literalValue)

Parameters

literalName
The name of the static field.
literalValue
The constant value of the literal.

Returns

The defined field.

Remarks

The defined field will have the field attributes System.Reflection.FieldAttributes.Public, System.Reflection.FieldAttributes.Static, and System.Reflection.FieldAttributes.Literal set.

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.

Requirements

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