Is there a case where delegate syntax is preferred over lambda expression for anonymous methods?

前端 未结 7 1527
别跟我提以往
别跟我提以往 2021-02-07 21:13

With the advent of new features like lambda expressions (inline code), does it mean we dont have to use delegates or anonymous methods anymore? In almost all the samples I have

相关标签:
7条回答
  • 2021-02-07 21:56

    Delegate have two meanings in C#.

    The keyword delegate can be used to define a function signature type. This is usually used when defininge the signature of higher-order functions, i.e. functions that take other functions as arguments. This use of delegate is still relevant.

    The delegate keyword can also be used to define an inline anonymous function. In the case where the function is just a single expression, the lambda syntax is a simpler alternative.

    0 讨论(0)
提交回复
热议问题