I want to have an event that takes an enum only as the argument. For example
public enum MyEvents{
Event1
}
// how do I declare this to take enum MyEvents as argument
public static event EventHandler EventTriggered;
public static void Trigger(MyEvent event )
{
if (EventTriggered != null)
{
EventTriggered(event);
}
}
You declare a delegate for the parameters:
Although all events in the framework takes a parameter that is or derives from
EventArgs, you can use any parameters you like. However, people are likely to expect the pattern used in the framework, which might make your code harder to follow.