I recommend that you do not use the word type, and you need to parse the enumeration:
set { employeeType = (Type)Enum.Parse(typeof(Type), value); }
Edit:
First, I cannot repeat enough not to use the word Type to enumerate OR strings to return a property. Secondly, using the enumerations here with the switch may cause you problems, but by default you can free you.
public enum WorkType { Hourly = 1, Salary = 2, None = 3 };
I suspect that the problem you are working with in the conversion is that you are using an assignment that is not a type string:
WorkType someType = WorkType.None; this.EmployeeType = someType; // Exception is here
This is not a valid case because someType is a type and EmployeeType (value) is a string. To fix this, you need to assign it:
this.EmployeeType = someType.ToString();
It all boils down to pretty dumb because it can be achieved with something simple:
public enum WorkType { Hourly = 1, Salary = 2, None = 3 }; public WorkType EmployeeType { get; set; }
source share