Converting Types in runtime using reflection?
See the question and my original answer on StackOverflowGeneralized type conversion is quite poor and inconsistent (in my opinion) in .NET. However for the Enum / int case, you can use the IConvertible interface, or the Convert associated utility class:
int converted = (int)Convert.ChangeType(MyEnum.MyValue, typeof(int));
or
object converted = Convert.ChangeType(myValue, myExpectedType);
As a site note, this 100% free library here: CodeFluentRuntimeClient has a class named ConvertUtilities
that has a bunch of ChangeType method overloads (including a generic one) that are very versatile and useful for type conversion.