how to cast string enum ?
i have the code below , it gives me error when i try to assign string to levelEnum, where levelEnum is an Enumeration..
foreach (CustomProperty prop in requirementTemplate.AttributesCustomList)
{
if (prop.Name == property)
{
return (CRF_DB.CRF_Requirement.LevelEnum) (prop.Value.ToString());
}
}
Is there a way to put select Enum item by assigning value to it ?
hope it is clear enough
Try the following
return (CRF_DB.CRF_Requirement.LevelEnum)Enum.Parse(
typeof(CRF_DB.CRF_Requirement.LevelEnum),
prop.Value.ToString());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With