I think this question needs some code:
private TypeValues GetEnumValues(Type enumType, string description)
{
TypeValues wtv = new TypeValues();
wtv.TypeValueDescription = description;
List<string> values = Enum.GetNames(enumType).ToList();
foreach (string v in values)
{
//how to get the integer value of the enum value 'v' ?????
wtv.TypeValues.Add(new TypeValue() { Code = v, Description = v });
}
return wtv;
}
Call it like this:
GetEnumValues(typeof(AanhefType), "some name");
In the GetEnumValues function i have the values of the enum. So i iterate the values and i want to get the integer value of that enum value also.
So my values are 'red' and 'green', and i also want to get 0 and 1.
When i have the Enum in my function, i can create the enum value from the string and cast it to that enum and then cast it to an int, but in this case, i don't have the enum itself, but only the type of the enum.
I tried passing in the actual enum as a parameter too, but i'm not allowed to pass an enum as a parameter.
So now i'm stuck.....