Should I Create a New Delegate Instance?

前端 未结 2 1750
感情败类
感情败类 2020-12-19 04:02

What are the implications of doing this...

this.myButton.Click += new EventHandler(this.myButton_Clicked);

...versus this?

         


        
2条回答
  •  南方客
    南方客 (楼主)
    2020-12-19 04:34

    Yes, the second version makes the compiler create an implicit delegate, much like you can specify this.MyMethod instead of new Action(this.MyMethod) or new Action(() => this.MyMethod()).

提交回复
热议问题