博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Linq三种查询
阅读量:7086 次
发布时间:2019-06-28

本文共 672 字,大约阅读时间需要 2 分钟。

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();
        }
    }
}

转载于:https://www.cnblogs.com/sulong/p/4808007.html

你可能感兴趣的文章
Centos中vim的配置
查看>>
PowerShell 实现邮箱收发数量统计
查看>>
2014年中国互联网企业100强(完整版榜单)
查看>>
解决win7打印机共享 出现“无法保存打印机设置,操作无法完成(错误0x000006d9)”...
查看>>
一致性协议算法-------------Paxos算法
查看>>
ubuntu 16.04 安装使用composer
查看>>
runtime.exec()
查看>>
深度学习(一)深度学习学习资料
查看>>
ES学习笔记之health api的实现
查看>>
dz模板引擎分析
查看>>
java面向对象-1
查看>>
[RabbitMQ+Python入门经典] 兔子和兔子窝
查看>>
wget离线下载文档
查看>>
用友软件操作流程(新建年度帐、年度结转步骤
查看>>
程序员
查看>>
杭州某公司技术一面
查看>>
我的友情链接
查看>>
在word里面写完文章在里面添加本机的图标
查看>>
我的友情链接
查看>>
cp: omitting directory `foldera/'
查看>>