C# Action/Delegate Style Question

.net, c#, coding-style

Solution

Neither 1 or 2. A third option is the winner

public event EventHandler<NumberChangedEventArgs> NumberChanged;

You're breaking a number of style guidelines for developing in C#, such as using a type for event args that doesn't extend EventArgs.

Yes, you can do it this way, as the compiler doesn't care. However, people reading your code will do a WTF.

Problem

What is considered better style for an event definition: ``` public event Action<object, double> OnNumberChanged; ``` or ``` public delegate void DNumberChanged(object sender, double number); public event DNumberChanged OnNumberChanged; ``` The first takes less typing, but the delegate one gives names to the parameters. As I type this, I think number 2 is the winner, but I could be wrong. Edit: A different (third) approach is the winner. Read below.

Original source