Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何创建函数列表<;T1、T2、out T3>;_C#_Linq_Lambda - Fatal编程技术网

C# 如何创建函数列表<;T1、T2、out T3>;

C# 如何创建函数列表<;T1、T2、out T3>;,c#,linq,lambda,C#,Linq,Lambda,我想这比我想象的要简单 我可以创建一个Func列表,然后添加到其中 var x = new List<Func<IBQCustomer, string>>(); x.Add(c => c.FullName); “OrderByDirection”枚举不是函数参数?在这种情况下,您可以使用以下内容: var y = new List<Tuple<Func<IBQCustomer, string>, OrderByDirection>&g

我想这比我想象的要简单

我可以创建一个Func列表,然后添加到其中

var x = new List<Func<IBQCustomer, string>>();
x.Add(c => c.FullName);

“OrderByDirection”枚举不是函数参数?在这种情况下,您可以使用以下内容:

var y = new List<Tuple<Func<IBQCustomer, string>, OrderByDirection>>();
y.Add(new Tuple<Func<IBQCustomer, string>, OrderByDirection>(c => c.FullName, OrderByDirection.Asc));
var y=new List();
y、 添加(新元组(c=>c.FullName,OrderByDirection.Asc));
当然,您也可以使用自定义类而不是“Tuple”:

class-MyClass
{
公共职能;
公共秩序方向;
}
或者你可能把lambda表达式写错了?这应该起作用:

var y = new List<Func<IBQCustomer, OrderByDirection, string>>();
y.Add((c, d) => c.FullName);
var y=new List();
y、 添加((c,d)=>c.FullName);

“OrderByDirection”枚举不是函数参数吗?在这种情况下,您可以使用以下内容:

var y = new List<Tuple<Func<IBQCustomer, string>, OrderByDirection>>();
y.Add(new Tuple<Func<IBQCustomer, string>, OrderByDirection>(c => c.FullName, OrderByDirection.Asc));
var y=new List();
y、 添加(新元组(c=>c.FullName,OrderByDirection.Asc));
当然,您也可以使用自定义类而不是“Tuple”:

class-MyClass
{
公共职能;
公共秩序方向;
}
或者你可能把lambda表达式写错了?这应该起作用:

var y = new List<Func<IBQCustomer, OrderByDirection, string>>();
y.Add((c, d) => c.FullName);
var y=new List();
y、 添加((c,d)=>c.FullName);

您可以使用以下多个参数声明匿名委托:

y.Add((customer, direction) => customer.FullName);

那就行了。调用列表中每个委托的任何对象都必须提供两个参数,
IBQCustomer
OrderByDirection

您可以使用以下多个参数声明匿名委托:

y.Add((customer, direction) => customer.FullName);

那就行了。调用列表中每个委托的任何对象都必须提供两个参数,
IBQCustomer
OrderByDirection

“…”=“我不知道在这里放置什么来将项目添加到我的列表中”上面添加了一个错误:您想要一个额外的参数还是一个额外的返回值?额外的参数-最终想要3个参数…但不是贪婪;)e、 g.建立一个Func列表,以便我以后可以使用它顺便说一句:可以使用包含所有参数的类,但这似乎不是必需的?”…“=“我不知道在这里放置什么来向我的列表添加项目”上面添加了一个错误:您想要一个额外的参数还是一个额外的返回值?额外的参数-最终想要3个参数…但不是贪婪;)e、 g.建立一个Func列表,这样我以后就可以使用它了顺便说一句:可以用一个包含所有参数的类来做,但这似乎不是必需的?