I'm developing an app for Windows Store app and I have code like this.
public enum Categories { Cat1, Cat2, Cat3 } Is there any option to convert string[] cats = {"categoty 1", "category 2", "category 3"} to Enum?
I've tried using EnumMember attribute:
[DataContract] public enum Categories { [EnumMember(Value = "category 1")] Cat1, [EnumMember(Value = "category 2")] Cat2, [EnumMember(Value = "category 3")] Cat3 } ...but still no luck with var cat = Enum.Parse(typeof(Categories), cats[0]);:
Exception thrown: 'System.ArgumentException' in mscorlib.ni.dll Requested value 'category 1' was not found. Any ideas?
Dictionary<string,Categories>that maps the string to the enum value.