标签:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
/*
* 1、Linq查询结果有两种类型:一个是枚举,一个是标量(scalar)
*/
namespace Linq三种查询
{
class Program
{
static void Main(string[] args)
{
int[] numbers = { 12,23,34,45,56,67,78,89};
var numbersQuery = from n in numbers
where n > 10
select n;
var numberMothod = numbers.Where(n =>n >10);
int count = (from n in numbers where n > 10
select n).Count();
foreach (var x in numbersQuery)
Console.Write("{0}\t",x);
Console.WriteLine();
foreach (var x in numberMothod)
Console.Write("{0}\t", x);
Console.WriteLine();
Console.WriteLine(count);
Console.ReadKey();
}
}
}
Linq三种查询
标签:
原文地址:http://www.cnblogs.com/sulong/p/4808007.html