Convert a string to an enumerated (enum) value

Last post 07-08-2009 2:33 AM by nijhawan.saurabh. 1 replies.

Sort Posts:

  • Convert a string to an enumerated (enum) value

    07-07-2009, 9:23 AM

     Using Enum.Parse you can convert the any string to enum

    example:

    private enum Aircraft
    {
      A,
      V,
      C
    }

    Aircraft air = (Aircraft) Enum.Parse(typeof(Aircraft), "C", true);

    Navin
    Filed under:
  • Re: Convert a string to an enumerated (enum) value

    07-08-2009, 2:33 AM

    Cool trick thx!

    Saurabh Nijhawan(B.Tech. CSE,GGSIPU,New Delhi)
    Application Architect, Eminent Solutions, New Delhi.
    Freelancer | Teacher
    Remember to click "Mark as Answer" on the post, if it helped you.
    ASP.NET Weblog
    http://www.saurabhnijhawan.com
    Learning Made Easy

    There's nothing more than to be Alive, think twice before you kill or are a reason for an Animal's killing..
    Against Animal Killing
Page 1 of 1 (2 items)