c# - 我们什么时候应该使用 Action<T> 而不是创建自定义委托(delegate)

标签 c# delegates

我们什么时候应该使用 Action<T>而不是显式定义委托(delegate)?

最佳答案

嗯...

Action<T> is almost the same as delegate void (T t)
and
Func<T> is almost the same as delegate T ()

Action 和 Func(以及 lambda)只是“语法糖”和使用委托(delegate)的便利。

所以这实际上只是一个偏好问题。

关于c# - 我们什么时候应该使用 Action<T> 而不是创建自定义委托(delegate),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13240503/

相关文章:

c# - PrinterSettings.InstalledPrinters 未获取网络打印机

ios - 是否有必要在 swift iOS 中使用扩展来定义委托(delegate)方法

ios - 未调用 MFMailComposeViewController 委托(delegate)方法

c# - 这两个 C# 方法有什么区别

c# - C#6 "using static"特性的正确使用方法

c# - 如何在运行时加载的程序集中使用公共(public) log4net 引用?

c# - 无法修改 Controls 集合,因为该控件包含代码块(即 <% ... %>)

c# - 创建具有任意参数的委托(delegate)

c# - 如何定义具有 N 个参数的委托(delegate)函数

c# - 条件委托(delegate)?