关于where方法的使用
1、public static IEnumerable<TSource> Where<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate);
2、public static IEnumerable<TSource> Where<TSource>(this IEnumerable<TSource> source, Func<TSource, int,bool> predicate);
有几个疑问:
1、Where方法的参数是Function<T,bool>类型的委托,这个委托就是predicate?是这个意思?
2、看书上的示例,如下:
int sum1 = nums.Where(n=>n%4==0).Sum();
在nums后面有点操作符,属于调用集合对象的方法。
有时却没有使用点操作符,例如:
var result = from b in ds.Tables["tb_Bookinfo"].AsEnumerable() where b.Field<DateTime>("b_pub_date").Month ==3
aelect new
{
......
}