C# Delegate Instantiation vs. Just Passing the Method Reference

后端 未结 3 694
夕颜
夕颜 2020-12-02 00:00

I have a simple question: what\'s the advantage of instantiating a C# delegate as opposed to just passing the function reference? What I mean is:

Why do:

         


        
3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-02 00:30

    The compiler will infer that when you typed the shorter code, you meant the longer code. There's no difference in the ultimate effect. If you want the clarity of the full constructor, you can put it in; if you want the brevity of just the method group, you can allow the compiler to infer the constructor. It's just a stylistic choice.

提交回复
热议问题