首页 > 其他 > 详细

Linq三种查询

时间:2015-09-14 21:06:11      阅读:303      评论:0      收藏:0      [点我收藏+]
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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!