Because Enums aren't guaranteed to be of type int...
public enum ExampleEnum : int / ulong / whatever
You cannot do this with enums:
int i = (int)exampleEnum;
However in my case, while I don't know the exact 'type of enum' being used, I can guarantee that it will be a "int type" of enum.
So I can do this:
int i = Convert.ToInt32(exampleEnum);
Cool. Here's the problem: I don't know of a way to do the inverse (which I need to do), as:
Enum exampleEnum = (Enum)exampleEnum;
has error:
Cannot cast expression of type 'int' to type 'Enum'
And I cannot find an inverse of Convert.ToInt32(Enum enum)
That is the question, if you think more detail on what I'm trying to do is useful, I can provide you with it. But in a nutshell I am creating a generic GUI method that takes in any type of Enum:
public static int EditorPrefEnumField(string label, Enum defaultValue, string editorPrefString)
and getting it to work (the way I want) involves converting the Enum to and from an int.