Simply type cast the enum to an int.
enum Side
{
Left,
Right,
Top,
Bottom
}
int value = (int)Side.Left;
The above will work for the vast majority of enums
as the default underlying type for an enum is int.
However, enums can have different underlying types. If an enum is
declared as a uint, long, or ulong,
it should be cast to the type of the enum. Here's an example for long:
enum Planet : long
{
Mars = 137726861,
Jupiter = 2039382280,
Saturn = 2647483649
}
long value = (long)Planet.Saturn;
in Austin, Texas. - vsn 44.0.0