none
Type to Enum RRS feed

  • Question

  • Hello,

    I have an Enum as follows:

    public enum TypeEnum {
      Int32,
      String,
      Boolean
    }

    And I am trying to get the Enum value when I have a type so I tried:

    TypeEnum typeEnum = (TypeEnum)Enum.Parse(typeof(TypeEnum), myType.ToString())

    But I got the following error: "Requested value 'System.Int32' was not found"

    So what I would like to get is the Type without the System: Int32, String, Boolean, etc.

    What is the best way to do this?

    Thank you,

    Miguel

    Thursday, February 23, 2012 4:13 PM

Answers

All replies