c# - Func<...> args 有 "unnamed"个参数。有没有办法给它们命名?

标签 c# .net generics func

有没有一种方法可以命名泛型 Func<...> 的参数以支持智能感知?

例子:

Func<int, int, int> f1 = new Func<int, int, int>(
    (a, b) => { return a + b }
);

f1(2, 3);

enter image description here

最佳答案

没有。不过,您可以定义自己的委托(delegate)/接口(interface)。

public delegate int DoTheThing(int a, int b);

public interface IThingDoer {
    int DoTheThing(int a, int b);
}

关于c# - Func<...> args 有 "unnamed"个参数。有没有办法给它们命名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71203523/

相关文章:

.net - 避免大量传播暴露给 ViewModel 的属性和事件

c# - 在 Powershell 中,如何使用字节数组作为 C# 通用类之一的键类型?

c++ - 如何为表达式解析器的派生类对象设置和取消引用通用指针?

c# - 我想为使用 Linq To Sql 读取的数据集中的每条记录添加一个唯一 ID

c# - 编辑器模板中的Ajax

.net - 使用 System.Text.UnicodeEncoding.Unicode.GetString(byte[]) 反向编码字节数组时间歇性失败

c# - ASP.NET Core 模型绑定(bind)错误消息在 ASP.NET CORE 2.0 中的本地化

java - 给定 `T` 和 `U` 其中 `T extends U` 如何返回 `U`

c# - 关于 Environment.SpecialFolder

c# - .net 中的 "new "关键字实际上是做什么的?