zoukankan      html  css  js  c++  java
  • Linq源代码阅读

    在 System.Core

    dotnet451source dpfxsrccoresystemlinqenumerable.cs

    Where 和 Select 内 ,把数组和List分开,没看明白为什么这么做

    if (source is Iterator<TSource>) return ((Iterator<TSource>)source).Where(predicate);
    if (source is TSource[]) return new WhereArrayIterator<TSource>((TSource[])source, predicate);
    if (source is List<TSource>) return new WhereListIterator<TSource>((List<TSource>)source, predicate);

    ----------------------

    Union,Intersect,Except,Distinct 防止重复 用Set,类似HashSet一个内部使用的,没明白为什么不用Hashset,可能是为了简化?

    HashSet类似用字典,但是只有Key,没有Value

    Union,联合,A + B, 加后元素都不会重复。

    Intersect  交集, A和B共同有的, A如果本来有重复的元素,也只取一个,

      Join A B类型不同,Intersect类型相同

    Except 差集,A有 B没有的元素 ,A如果本来有重复的元素,也只取一个

    -------------------

    SequenceEqual 两个序列元素比较,长度也要一样

    AsEnumerable 没有任何意义

     IEnumerable<TResult> OfType<TResult>(this IEnumerable source)  只返回source里 TResult类型的。

    OfType 用的is type ,Cast用的(TResult)type ,可能转 double 到int适合Cast

    ----------------------------------------

    Join以前看过,排序和分组的没仔细看。

  • 相关阅读:
    自动化部署功
    docker 安装
    批量操作
    centos7 内核升级
    centos 6.5 升级 内核
    如何进行再linux 下查看 java程序的堆栈信息
    binlog 日志恢复以及操作
    java 中 Integer 比较 问题
    docker 使用
    soucetree 安装
  • 原文地址:https://www.cnblogs.com/peteryu007/p/6343964.html
Copyright © 2011-2022 走看看