convert an enum to another type of enum

Given Enum1 value = ..., then if you mean by name:

Enum2 value2 = (Enum2) Enum.Parse(typeof(Enum2), value.ToString());

If you mean by numeric value, you can usually just cast:

Enum2 value2 = (Enum2)value;

(with the cast, you might want to use Enum.IsDefined to check for valid values, though)

Leave a Comment