public static CharacterClass GetCharacterClass(int id) { var vals = Enum.GetValues(typeof(CharacterRace)); foreach (var val in vals) { CharacterClass cl = (CharacterClass)val; if (cl.GetCharacterClassId() == id) { return(cl); } } return(CharacterClass.Mage); }