Getting the value of an enum

Discussion in 'ASP .Net' started by Mark Fox, Nov 14, 2003.

  1. Mark Fox

    Mark Fox Guest

    Hello,

    I have a simple question. If there is an enum:

    public enum Hello
    {
    First = 1,
    Second = 2,
    Third = 3
    }

    How do I get the integer value for the selected enum.

    Hello thisHello = Hello.Second;
    int SelectedValue = [??thisHello.Value??];

    Thanks for your help!
     
    Mark Fox, Nov 14, 2003
    #1
    1. Advertisements

  2. int SelectedValue = (int) thisHello;
     
    John Saunders, Nov 14, 2003
    #2
    1. Advertisements

  3. Mark Fox

    Mark Fox Guest

    Thanks John! That answers my question.
     
    Mark Fox, Nov 14, 2003
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.