Extensions work on instances, not for creating static methods. You can extend the base Enum using public static void MyExtensions(this Enum value)
. But this would still only create methods on Enum instances you create. The only way to add static methods like you're talking about externally for a class is if the class is a partial class.
Edit: to do something like you want I wrote the following
public static bool IsFlagSet<T>(this Enum value, Enum flag)
{
if (!typeof(T).IsEnum) throw new ArgumentException();
if (value == flag) return true;
return ((int)Enum.Parse(typeof(T), value.ToString()) &
(int)Enum.Parse(typeof(T), flag.ToString())) != 0;
}
*warning, this method needs to be thought out more prior to use, I'm hoping there is a better way to do it.