using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplicationExeiciseLinq
{
class Program
{
static void Main(string[] args)
{
int[] nums = {1,2,3,4,5,6,7,8,9,10 };
//简单Linq查询
var mynum = from num in nums where num.Equals(2) select num;
Console.WriteLine(mynum.ToArray()[0]);
var mynum1 = from num in nums where num>2&&num<5 select num;
Console.WriteLine(mynum1.ToArray()[1]);
//分页排序
var mynum2 = nums.Skip(2).Take(5);
foreach (var item in mynum2)
{
Console.WriteLine(item);
}
Console.WriteLine("-----------");
var mytest = from t in nums where t>3 select t;
Console.WriteLine("数目是:"+mytest.Count());
Console.WriteLine("-----------");
var mytest2 = nums.First(c=>c>1);
Console.WriteLine(mytest2.ToString());
Console.ReadKey();
}
}
}