C# why shall I use “new” keyword when subscribing for an event?

前端 未结 4 1569
长情又很酷
长情又很酷 2021-01-14 01:23

What is the difference between following 2 ways of subscribing for an event?

receiver.ConfigChanged += Config_ConfigChanged;

receiver.ConfigChanged += new E         


        
4条回答
  •  北荒
    北荒 (楼主)
    2021-01-14 02:05

    Visual Studio's TAB event auto-complete always defaults to the .Net 1.0 way of doing things regardless of what edition of the framework you are using. You may find some people who are used to reading the older way of doing things. I only came across the less verbose way through using Resharper!

    Here's an MSDN article on event subscription - it says exactly what @CodeInChaos just confirmed: http://msdn.microsoft.com/en-us/library/ms366768%28v=vs.80%29.aspx

提交回复
热议问题