static T GetEnumValue <T>(string message, params object[] args) where T : struct { if (!typeof(T).IsEnum) { return(default(T)); } string t; T val; int i = 0; do { Console.Write("{0} {1}", ++i, string.Format(message, args)); t = Console.ReadLine(); }while (!EnumUtil.EnumTryParse(t, out val)); Console.WriteLine(); return(val); }