Should I instantiate a new delegate or not?

前端 未结 2 847
既然无缘
既然无缘 2020-12-17 01:38

I just realized I can add an event handler in two ways:

Consider an event handler like so:

private void MyEventHandler()
{}

Method

2条回答
  •  无人及你
    2020-12-17 02:21

    There is no difference, the generated IL is the same. The shorter form was introduced in .net/c# 2.0 as a convenience function, although Visual Studio still does the first form on Tab Completion.

    See this question for some more info.

提交回复
热议问题