C#: Difference between ‘ += anEvent’ and ‘ += new EventHandler(anEvent)’

There is no difference. In your first example, the compiler will automatically infer the delegate you would like to instantiate. In the second example, you explicitly define the delegate.

Delegate inference was added in C# 2.0. So for C# 1.0 projects, second example was your only option. For 2.0 projects, the first example using inference is what I would prefer to use and see in the codebase – since it is more concise.

Leave a Comment