Func delegate with no return type

前端 未结 7 1203
温柔的废话
温柔的废话 2020-12-02 03:54

All of the Func delegates return a value. What are the .NET delegates that can be used with methods that return void?

7条回答
  •  没有蜡笔的小新
    2020-12-02 04:33

    Occasionally you will want to write a delegate for event handling, in which case you can take advantage of System.EvenHandler which implicitly accepts an argument of type object in addition to the second parameter that should derive from EventArgs. EventHandlers will return void

    I personally found this useful during testing for creating a one-off callback in a function body.

提交回复
热议问题