Foreach on enum types in template
问题 enum MyEnum { type1, type2, type3 } public void MyMethod<T>() { ... } How to make forach on enum to fire MyMethod<T> on every enum? I try something with foreach (MyEnum type in Enum.GetValues(typeof(MyEnum))) {...} But still don't know how to use this type inside foreach with MyMethod<T> as T 回答1: Is this what you are trying to do? class Program { static void Main(string[] args) { EnumForEach<MyEnum>(MyMethod); } public static void EnumForEach<T>(Action<T> action) { if(!typeof(T).IsEnum)