C# 如何为特定签名编写内联lambda表达式
这让我的大脑融化了。给定C# 如何为特定签名编写内联lambda表达式,c#,lambda,C#,Lambda,这让我的大脑融化了。给定iaapplicationbuilder的这些签名,如何编写满足扩展方法的lambda表达式 public IApplicationBuilder Use(Func<RequestDelegate, RequestDelegate> middleware) 公共IApplicationBuilder使用(Func中间件) 扩展方法:(我想满足这个扩展) 公共静态IApplicationBuilder使用(此IApplicationBuilder应用程序,F
iaapplicationbuilder
的这些签名,如何编写满足扩展方法的lambda表达式
public IApplicationBuilder Use(Func<RequestDelegate, RequestDelegate> middleware)
公共IApplicationBuilder使用(Func中间件)
扩展方法:(我想满足这个扩展)
公共静态IApplicationBuilder使用(此IApplicationBuilder应用程序,Func中间件)
这就是我现在拥有的:
app.Map("/home/abc", config =>
{
config.Use(async (context, next) => // this matches Func<RequestDelegate, RequestDelegate>
{
});
});
app.Map(“/home/abc”,config=>
{
config.Use(async(context,next)=>//这与Func匹配
{
});
});
我的表达式实际上是正确的。看起来这是VS2015 RC中的某种Roslyn/intellisense bug。如果存在任何未解析的引用或任何在lambda表达式内部报告为红色曲线的内容,那么VS goes bonkers会报告它们不是的类型的变量
我想知道这是否存在于以前版本的VS中,我只是从来没有遇到过
我看不出这与
Func
有什么匹配。这样的lambda只有一个参数,而您有两个。你看到的问题是什么?这是一个错误吗?你确定你不只是缺少一个使用语句的?
app.Map("/home/abc", config =>
{
config.Use(async (context, next) => // this matches Func<RequestDelegate, RequestDelegate>
{
});
});