In vs2008, is it possible to write an extension methods which would apply to any enumeration.
I know you can write extension methods against a specific enumeration,
Here's another example - also nicer IMHO than having to create and initialize a temp variable.
public static class ExtensionMethods
{
public static void ForEach(this Enum enumType, Action action)
{
foreach (var type in Enum.GetValues(enumType.GetType()))
{
action((Enum)type);
}
}
}
public enum TestEnum { A,B,C }
public void TestMethod()
{
default(TestEnum).ForEach(Console.WriteLine);
}