How to convert delegate to identical delegate?

后端 未结 5 2040
你的背包
你的背包 2021-02-18 19:04

There are two descriptions of the delegate: first, in a third-party assembly:

public delegate void ClickMenuItem (object sender, EventArgs e)

s

5条回答
  •  -上瘾入骨i
    2021-02-18 19:08

    You may like to checkout Variance in Delegates.

    .NET Framework 3.5 and Visual Studio 2008 introduced variance support for matching method signatures with delegate types in all delegates in C# and Visual Basic. This means that you can assign to delegates not only methods that have matching signatures, but also methods that return more derived types (covariance) or that accept parameters that have less derived types (contravariance) than that specified by the delegate type. This includes both generic and non-generic delegates.

提交回复
热议问题