c# - 分配一个接受参数的委托(delegate)

标签 c# .net c#-3.0 delegates

我正在查看 BackgroundWorker.ReportProgress 方法。它可以带 1 个参数 (int) 或两个参数 (int, object)。

如果我想像这样分配 ReportProgress:

var ReportProgressMethod = backgroundWorker.ReportProgress;

我收到一条错误消息,指出存在不明确的引用,因为(当然)该方法可以采用参数集。

我怎样才能将上面的语句更改为我想使用该方法的 int, object 版本。

(这背后的想法是我想将 ReportProgressMethod 作为参数传递给方法。)

最佳答案

Action<int, object> reportProgressMethod = backgroundWorker.ReportProgress;

关于c# - 分配一个接受参数的委托(delegate),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2220045/

相关文章:

c# - jquery "async = true"调用.net web 服务不异步工作

.net - 如何使用反射器将整个程序集转储到源文件?

.net - 为可以在 Windows 和 OS X 上运行的 .NET 应用程序构建安装程序?

c# - 将 DateTime 绑定(bind)到日期和时间 EditFields

c# - 无法反序列化从其他应用程序保存的属性类型数组

c# - Windows 8.1 应用向上滑动打开应用栏并向上滑动关闭应用栏 - 这是默认行为吗?

c# - mysql datareader 找不到行 c#

c# - C# 3.0 中的 var 关键字

C# 绑定(bind)列表由绑定(bind)列表组成

asp.net-mvc - 在C#中,如何从byte[]得知文件类型?