SubareaOpr

//构造数组序列
int[] arr = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
var query1 = arr.Skip(8);//跳过8个元素取值
Response.Write("arr.Skip(8):<br/>");//结果等于8,9
foreach (var item in query1) { Response.Write(item + " , "); }
Response.Write("<br/>");

var query2 = arr.SkipWhile(itm =>itm <8);//跳过小于8的元素取值
Response.Write("arr.SkipWhile(itm =>itm <8):<br/>");//结果等于8,9
foreach (var item in query2) { Response.Write(item + " , "); }
Response.Write("<br/>");

var query3 = arr.Take(2);//取序列的头两个元素
Response.Write("arr.Take(2):<br/>");//结果等于0,1
foreach (var item in query3) { Response.Write(item + " , "); }
Response.Write("<br/>");

var query4 = arr.TakeWhile(itm =>itm<2);//从头开始取小于2的元素
Response.Write("arr.TakeWhile(itm =>itm<2):<br/>");//结果等于0,1
foreach (var item in query4) { Response.Write(item + " , "); }
Response.Write("<br/>");

posted @ 2013-01-18 16:51  yellowshorts  阅读(111)  评论(0编辑  收藏  举报