随笔分类 -  Linq

Linq 
Linq学习笔记--延迟操作符(排序操作符)
摘要:4.排序操作符 OrderBy 作用:基于一个keySelector方法对输入序列进行排序,keySelector方法 将为每个输入元素返回一个键值,并会生成一个已排序的输出序列 IOrderedEnumerable<T>,这个输出序列将根据返回的键值按升序排列。 原型 public static IOrderedEnumerable<T> OrderBy<T, K>( th... 阅读全文
posted @ 2012-05-07 16:47 无名小虾 阅读(304) 评论(0) 推荐(0) 编辑
Linq学习笔记--延迟操作符(分区操作符)
摘要:3.分区操作符Take作用:可以返回来自输入序列中指定数量的元素,并从输入序列的第一个元素开始计数。简单的说就是获取序列中的前几项原型 public static IEnumerable<T> Take<T>( this IEnumerable<T> source,int count);例子 static void Main(string[] args) { string[] items = { "Hello World", "Welcome to MVC", "Linq to Sql"}; var 阅读全文
posted @ 2012-05-07 16:42 无名小虾 阅读(256) 评论(0) 推荐(0) 编辑
Linq学习笔记--延迟操作符(投影操作符)
摘要:2.投影操作符Select作用:从某种类型的元素组成的输入序列创建一个由其他类型的元素组成的输出序列。输入的类型和输出的类型不必相同。原型 public static IEnumerable<S> Select<T, S>( this IEnumerable<T> source, Func<T, S> selector); public static IEnumerable<S> Select<T, S>( this IEnumerable<T> source, Func<T, int, S> se 阅读全文
posted @ 2012-05-07 16:39 无名小虾 阅读(312) 评论(0) 推荐(0) 编辑
Linq学习笔记--延迟操作符(限定操作符)
摘要:延迟操作符:凡是IEnumerable<T>或IOrderedEnumerable<T>类型的值的操作符都属于延迟操作符。1.限定操作符Where作用:用于将筛选出来的元素放到一个序列中原型 public static IEnumerable<T> Where<T>( this IEnumerable<T> source, Func<T,bool> predicate); public static IEnumerable<T> Where<T>( this IEnumerable<T> 阅读全文
posted @ 2012-04-10 11:23 无名小虾 阅读(202) 评论(0) 推荐(0) 编辑