The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

EnumBuilder.Name Property

Returns the name of this enum.

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

public override string Name { get; }

Property Value

Type: System.String
Read-only. The name of this enum.

The following code sample demonstrates the use of the Name property to reference the name of the current EnumBuilder.

using System;
using System.Reflection;
using System.Reflection.Emit;

class Example
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
      // Get the current application domain.
      AppDomain currentDomain = AppDomain.CurrentDomain;

      // Create a dynamic assembly in the current application domain, 
      // and allow it to be executed.
      AssemblyName aName = new AssemblyName("TempAssembly");
      AssemblyBuilder ab = currentDomain.DefineDynamicAssembly(aName, 

      // Define a dynamic module in "TempAssembly" assembly. The module can
      // have the same name as the assembly.
      ModuleBuilder mb = ab.DefineDynamicModule(aName.Name);

      // Define a public enumeration with the name "Elevation" and an 
      // underlying type of Integer.
      EnumBuilder eb = mb.DefineEnum("Elevation", 
         TypeAttributes.Public, typeof(int));

      // Define two members, "High" and "Low".
      eb.DefineLiteral("Low", 0);
      eb.DefineLiteral("High", 1);

      // Create the type.
      Type finished = eb.CreateType();

      foreach( FieldInfo fi in finished.GetFields() )
         outputBlock.Text += String.Format("{0}.{1} = {2}\n", 
            finished.Name, fi.Name, fi.GetRawConstantValue());

      outputBlock.Text += "Properties of EnumBuilder:  " + "\n";
      outputBlock.Text += "Assembly: " + eb.Assembly.ToString() + "\n";
      outputBlock.Text += "AssemblyQualifiedName: " + eb.AssemblyQualifiedName.ToString() + "\n";
      outputBlock.Text += "Module: " + eb.Module.ToString() + "\n";
      outputBlock.Text += "Name: " + eb.Name.ToString() + "\n";
      outputBlock.Text += "NameSpace: " + eb.Namespace + "\n";

/* This code example produces output similar to the following:

Elevation.Low = 0
Elevation.High = 1 
Properties of EnumBuilder: 
Assembly: TempAssembly, Version=, Culture=neutral, PublicKeyToken=null
AssemblyQualifiedName: Elevation, TempAssembly, Version=, Culture=neutral, PublicKeyToken=null
Module: RefEmit_InMemoryManifestModule
Name: Elevation


Supported in: 5, 4, 3

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft