Here is the code which defines a C# EventHandler, as written in the documentation, it represents the method that will handle an event that has no event data:

// Summary:// Represents the method that will handle an event that has no event data.//// Parameters:// sender:// The source of the event.//// e:// An System.EventArgs that contains no event data.
[Serializable]
[ComVisible(true)]
publicdelegatevoid EventHandler(object sender, EventArgs e);

There is another way to raise events, read about it in A New Pattern For Event Declaration. Anyway, we can define EventArgs as a private member and use it instead of allocating an EventArgs object every time the event is raised. Fortunately, there is no need for that, C# introduce us the EventArgs.Empty! So, this code should look like this:

I have to admit that I had a lot of thoughts wether to write this post or not. I was pretty sure that most of the developers know about that issue and I will only tell the obvious. But after doing a little research, I found out that ~40% of my colleagues didn’t use EventArgs.Empty so I realized that it might be new to some of Dev102 readers too. Please be honest, were you aware of this issue or not?