Enumerbale 类静态方法
扩展:
delegate TResult Func<in T1,in T2,out TResult>(T1 arg1, T2 arg2);
上面定义了一个委托,声明了一种方法的类型,什么类型呢?传入两个参数 arg1 和 arg2 这两个参数可以不同类型,返回一个结果,这个结果的类型还可以不同于参数的类型。至于方法中是怎么实现,并不做要求。
static void Main(string[] args) { Func<string, int, bool> f1 = FuncDemo; Console.WriteLine(f1("x",10)); } public static bool FuncDemo(string arg1, int arg2) { return string.IsNullOrEmpty(arg1 + arg2); }
Aggregate 聚集、聚合
三个函数重载
public static TSource Aggregate<TSource>(Func<TSource, TSource, TSource> func); public static TAccumulate Aggregate<TSource, TAccumulate>(TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func); public static TResult Aggregate<TSource, TAccumulate, TResult>(TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func, Func<TAccumulate, TResult> resultSelector);
对于第一个重载,要求传入的这个函数,对我的集合数据做操作
真正的大师永远怀着一颗学徒的心。

浙公网安备 33010602011771号