System.Linq.Enumerable 类

创建时间:
2014-02-28 08:34
最近更新:
2018-10-10 02:16

Overview

该类中的方法提供标准查询运算符的实现,该运算符用于查询实现 IEnumerable<T> 的数据源。
该类中的大多数方法被定义为扩展 IEnumerable<T> 的扩展方法。这意味着可以像调用实现 IEnumerable<T> 的任意对象上的实例方法一样调用它们。
网友总结:LINQ 里那些查询操作都是给 IEnumerable<T> 接口添加的扩展方法,这些方法在 LINQ 里被称为查询操作符,因此可以以方法调用的方式使用 LINQ。

Resource - MSDN

  1. System.Linq.Enumerable 类 - Provides a set of static (Shared in Visual Basic) methods for querying objects that implement IEnumerable<T>.
  2. 标准查询运算符按执行方式的分类 - 本页面列出了 System.Linq.Enumerable 类 中的所有方法与链接 (Zip 除外)
  1. Aggregate<TSource>(IEnumerable<TSource>, Func<TSource, TSource, TSource>) 对一个序列应用累加器函数。
  2. Aggregate<TSource, TAccumulate>(IEnumerable<TSource>, TAccumulate, Func<TAccumulate, TSource, TAccumulate>) 对一个序列应用累加器函数。 将指定的种子值用作累加器初始值。
  3. Aggregate<TSource, TAccumulate, TResult>(IEnumerable<TSource>, TAccumulate, Func<TAccumulate, TSource, TAccumulate>, Func<TAccumulate, TResult>) 对一个序列应用累加器函数。 将指定的种子值用作累加器的初始值,并使用指定的函数选择结果值。
  4. All<TSource>(IEnumerable<TSource>, Func<TSource, Boolean>) 确定是否对序列中的所有元素都满足条件。
  5. Any<TSource>(IEnumerable<TSource>) 确定序列是否包含任何元素。
  6. Any<TSource>(IEnumerable<TSource>, Func<TSource, Boolean>) 确定序列中是否存在元素满足条件。
  7. AsEnumerable<TSource>(IEnumerable<TSource>) 返回输入类型化为 IEnumerable<T>。
  8. Average(IEnumerable<Decimal>) 计算序列的平均值 Decimal 值。
  9. Average(IEnumerable<Double>) 计算序列的平均值 Double 值。
  10. Average(IEnumerable<Int32>) 计算序列的平均值 Int32 值。
  11. Average(IEnumerable<Int64>) 计算序列的平均值 Int64 值。
  12. Average(IEnumerable<Nullable<Decimal>>) 可以为 null 的序列的平均值,计算 Decimal 值。
  13. Average(IEnumerable<Nullable<Double>>) 可以为 null 的序列的平均值,计算 Double 值。
  14. Average(IEnumerable<Nullable<Int32>>) 计算可以为 null 的 Int32 值序列的平均值。
  15. Average(IEnumerable<Nullable<Int64>>) 可以为 null 的序列的平均值,计算 Int64 值。
  16. Average(IEnumerable<Nullable<Single>>) 可以为 null 的序列的平均值,计算 Single 值。
  17. Average(IEnumerable<Single>) 计算序列的平均值 Single 值。
  18. Average<TSource>(IEnumerable<TSource>, Func<TSource, Decimal>) 计算序列的平均值 Decimal 通过调用对输入序列中的每个元素的转换函数获得的值。
  19. Average<TSource>(IEnumerable<TSource>, Func<TSource, Double>) 计算序列的平均值 Double 通过调用对输入序列中的每个元素的转换函数获得的值。
  20. Average<TSource>(IEnumerable<TSource>, Func<TSource, Int32>) 计算序列的平均值 Int32 通过调用对输入序列中的每个元素的转换函数获得的值。
  21. Average<TSource>(IEnumerable<TSource>, Func<TSource, Int64>) 计算序列的平均值 Int64 通过调用对输入序列中的每个元素的转换函数获得的值。
  22. Average<TSource>(IEnumerable<TSource>, Func<TSource, Nullable<Decimal>>) 可以为 null 的序列的平均值,计算 Decimal 通过调用对输入序列中的每个元素的转换函数获得的值。
  23. Average<TSource>(IEnumerable<TSource>, Func<TSource, Nullable<Double>>) 可以为 null 的序列的平均值,计算 Double 通过调用对输入序列中的每个元素的转换函数获得的值。
  24. Average<TSource>(IEnumerable<TSource>, Func<TSource, Nullable<Int32>>) 可以为 null 的序列的平均值,计算 Int32 通过调用对输入序列中的每个元素的转换函数获得的值。
  25. Average<TSource>(IEnumerable<TSource>, Func<TSource, Nullable<Int64>>) 可以为 null 的序列的平均值,计算 Int64 通过调用对输入序列中的每个元素的转换函数获得的值。
  26. Average<TSource>(IEnumerable<TSource>, Func<TSource, Nullable<Single>>) 可以为 null 的序列的平均值,计算 Single 通过调用对输入序列中的每个元素的转换函数获得的值。
  27. Average<TSource>(IEnumerable<TSource>, Func<TSource, Single>) 计算序列的平均值 Single 通过调用对输入序列中的每个元素的转换函数获得的值。
  28. Cast<TResult>(IEnumerable) 将强制转换的元素 IEnumerable 为指定的类型。
  29. Concat<TSource>(IEnumerable<TSource>, IEnumerable<TSource>) 连接两个序列。
  30. Contains<TSource>(IEnumerable<TSource>, TSource) 确定序列是否包含指定的元素使用的默认相等比较器。
  31. Contains<TSource>(IEnumerable<TSource>, TSource, IEqualityComparer<TSource>) 确定序列是否使用指定的包含指定的元素 IEqualityComparer<T>。
  32. Count<TSource>(IEnumerable<TSource>) 返回序列中的元素数。
  33. Count<TSource>(IEnumerable<TSource>, Func<TSource, Boolean>) 返回一个数字来表示多少个元素指定序列中的满足条件。
  34. DefaultIfEmpty<TSource>(IEnumerable<TSource>) 返回单一实例集合中指定的序列或类型参数的默认值的元素,如果序列为空。
  35. DefaultIfEmpty<TSource>(IEnumerable<TSource>, TSource) 返回单一实例集合中指定的序列或指定的值的元素,如果序列为空。
  36. Distinct<TSource>(IEnumerable<TSource>) 通过使用的默认相等比较器对值进行比较从序列返回非重复元素。
  37. Distinct<TSource>(IEnumerable<TSource>, IEqualityComparer<TSource>) 返回序列中通过使用指定的非重复元素 IEqualityComparer<T> 对值进行比较。
  38. ElementAt<TSource>(IEnumerable<TSource>, Int32) 返回序列中的指定索引处的元素。
  39. ElementAtOrDefault<TSource>(IEnumerable<TSource>, Int32) 返回序列中指定索引处的元素;如果索引超出范围,则返回默认值。
  40. Empty<TResult>() 返回一个空 IEnumerable<T> 具有指定的类型参数。
  41. Except<TSource>(IEnumerable<TSource>, IEnumerable<TSource>) 通过使用默认的相等比较器对值进行比较,生成两个序列的差集。
  42. Except<TSource>(IEnumerable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>) 使用指定的生成两个序列的差集 IEqualityComparer<T> 对值进行比较。
  43. First<TSource>(IEnumerable<TSource>) 返回一个序列的第一个元素。
  44. First<TSource>(IEnumerable<TSource>, Func<TSource, Boolean>) 返回序列中满足指定条件的第一个元素。
  45. FirstOrDefault<TSource>(IEnumerable<TSource>) 返回序列中的第一个元素;如果序列中不包含任何元素,则返回默认值。
  46. FirstOrDefault<TSource>(IEnumerable<TSource>, Func<TSource, Boolean>) 返回序列中满足条件的第一个元素;如果未找到这样的元素,则返回默认值。
  47. GroupBy<TSource, TKey>(IEnumerable<TSource>, Func<TSource, TKey>) 根据指定的键选择器函数对序列的元素进行分组。
  48. GroupBy<TSource, TKey>(IEnumerable<TSource>, Func<TSource, TKey>, IEqualityComparer<TKey>) 根据指定的键选择器函数并将进行比较的键使用指定的比较器对序列的元素进行分组。
  49. GroupBy<TSource, TKey, TElement>(IEnumerable<TSource>, Func<TSource, TKey>, Func<TSource, TElement>) 根据指定的键选择器函数和项目的元素的每个组通过使用指定的函数对序列的元素进行分组。
  50. GroupBy<TSource, TKey, TElement>(IEnumerable<TSource>, Func<TSource, TKey>, Func<TSource, TElement>, IEqualityComparer<TKey>) 根据键选择器函数对序列的元素进行分组。 通过使用比较器对键进行比较,并且通过使用指定的函数对每个组的元素进行投影。
  51. GroupBy<TSource, TKey, TResult>(IEnumerable<TSource>, Func<TSource, TKey>, Func<TKey, IEnumerable<TSource>, TResult>) 根据指定的键选择器函数对序列中的元素进行分组,并且从每个组及其键中创建结果值。
  52. GroupBy<TSource, TKey, TResult>(IEnumerable<TSource>, Func<TSource, TKey>, Func<TKey, IEnumerable<TSource>, TResult>, IEqualityComparer<TKey>) 根据指定的键选择器函数对序列中的元素进行分组,并且从每个组及其键中创建结果值。 通过使用指定的比较器对键进行比较。
  53. GroupBy<TSource, TKey, TElement, TResult>(IEnumerable<TSource>, Func<TSource, TKey>, Func<TSource, TElement>, Func<TKey, IEnumerable<TElement>, TResult>) 根据指定的键选择器函数对序列中的元素进行分组,并且从每个组及其键中创建结果值。 通过使用指定的函数对每个组的元素进行投影。
  54. GroupBy<TSource, TKey, TElement, TResult>(IEnumerable<TSource>, Func<TSource, TKey>, Func<TSource, TElement>, Func<TKey, IEnumerable<TElement>, TResult>, IEqualityComparer<TKey>) 根据指定的键选择器函数对序列中的元素进行分组,并且从每个组及其键中创建结果值。 通过使用指定的比较器对键值进行比较,并且通过使用指定的函数对每个组的元素进行投影。
  55. GroupJoin<TOuter, TInner, TKey, TResult>(IEnumerable<TOuter>, IEnumerable<TInner>, Func<TOuter, TKey>, Func<TInner, TKey>, Func<TOuter, IEnumerable<TInner>, TResult>) 基于键相等对两个序列的元素进行关联,并对结果进行分组。 使用默认的相等比较器对键进行比较。
  56. GroupJoin<TOuter, TInner, TKey, TResult>(IEnumerable<TOuter>, IEnumerable<TInner>, Func<TOuter, TKey>, Func<TInner, TKey>, Func<TOuter, IEnumerable<TInner>, TResult>, IEqualityComparer<TKey>) 基于键相等对两个序列的元素进行关联,并对结果进行分组。 指定 IEqualityComparer<T> 用来对键进行比较。
  57. Intersect<TSource>(IEnumerable<TSource>, IEnumerable<TSource>) 通过使用的默认相等比较器对值进行比较,生成两个序列的交集。
  58. Intersect<TSource>(IEnumerable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>) 使用指定的生成两个序列的交集IEqualityComparer<T>值进行比较。
  59. Join<TOuter, TInner, TKey, TResult>(IEnumerable<TOuter>, IEnumerable<TInner>, Func<TOuter, TKey>, Func<TInner, TKey>, Func<TOuter, TInner, TResult>) 基于匹配键对两个序列的元素关联。 使用默认的相等比较器对键进行比较。
  60. Join<TOuter, TInner, TKey, TResult>(IEnumerable<TOuter>, IEnumerable<TInner>, Func<TOuter, TKey>, Func<TInner, TKey>, Func<TOuter, TInner, TResult>, IEqualityComparer<TKey>) 基于匹配键对两个序列的元素关联。 指定 IEqualityComparer<T> 用来对键进行比较。
  61. Last<TSource>(IEnumerable<TSource>) 返回一个序列的最后一个元素。
  62. Last<TSource>(IEnumerable<TSource>, Func<TSource, Boolean>) 返回序列中满足指定条件的最后一个元素。
  63. LastOrDefault<TSource>(IEnumerable<TSource>) 返回序列中的最后一个元素;如果序列中不包含任何元素,则返回默认值。
  64. LastOrDefault<TSource>(IEnumerable<TSource>, Func<TSource, Boolean>) 返回序列中满足条件的最后一个元素;如果未找到这样的元素,则返回默认值。
  65. LongCount<TSource>(IEnumerable<TSource>) 返回Int64表示序列中的元素总数。
  66. LongCount<TSource>(IEnumerable<TSource>, Func<TSource, Boolean>) 返回 Int64 表示序列中的多少个元素满足条件。
  67. Max(IEnumerable<Decimal>) 返回序列中的最大值 Decimal 值。
  68. Max(IEnumerable<Double>) 返回序列中的最大值 Double 值。
  69. Max(IEnumerable<Int32>) 返回序列中的最大值 Int32 值。
  70. Max(IEnumerable<Int64>) 返回序列中的最大值 Int64 值。
  71. Max(IEnumerable<Nullable<Decimal>>) 可以为 null 的序列中返回的最大值 Decimal 值。
  72. Max(IEnumerable<Nullable<Double>>) 可以为 null 的序列中返回的最大值 Double 值。
  73. Max(IEnumerable<Nullable<Int32>>) 可以为 null 的序列中返回的最大值 Int32 值。
  74. Max(IEnumerable<Nullable<Int64>>) 可以为 null 的序列中返回的最大值 Int64 值。
  75. Max(IEnumerable<Nullable<Single>>) 可以为 null 的序列中返回的最大值 Single 值。
  76. Max(IEnumerable<Single>) 返回序列中的最大值 Single 值。
  77. Max<TSource>(IEnumerable<TSource>) 泛型序列中返回的最大值。
  78. Max<TSource>(IEnumerable<TSource>, Func<TSource, Decimal>) 调用转换函数对序列的每个元素并返回最大 Decimal 值。
  79. Max<TSource>(IEnumerable<TSource>, Func<TSource, Double>) 调用转换函数对序列的每个元素并返回最大 Double 值。
  80. Max<TSource>(IEnumerable<TSource>, Func<TSource, Int32>) 调用转换函数对序列的每个元素并返回最大 Int32 值。
  81. Max<TSource>(IEnumerable<TSource>, Func<TSource, Int64>) 调用转换函数对序列的每个元素并返回最大 Int64 值。
  82. Max<TSource>(IEnumerable<TSource>, Func<TSource, Nullable<Decimal>>) 调用转换函数对序列的每个元素并返回最大可以为 null Decimal 值。
  83. Max<TSource>(IEnumerable<TSource>, Func<TSource, Nullable<Double>>) 调用转换函数对序列的每个元素并返回最大可以为 null Double 值。
  84. Max<TSource>(IEnumerable<TSource>, Func<TSource, Nullable<Int32>>) 调用转换函数对序列的每个元素并返回最大可以为 null Int32 值。
  85. Max<TSource>(IEnumerable<TSource>, Func<TSource, Nullable<Int64>>) 调用转换函数对序列的每个元素并返回最大可以为 null Int64 值。
  86. Max<TSource>(IEnumerable<TSource>, Func<TSource, Nullable<Single>>) 调用转换函数对序列的每个元素并返回最大可以为 null Single 值。
  87. Max<TSource>(IEnumerable<TSource>, Func<TSource, Single>) 调用转换函数对序列的每个元素并返回最大 Single 值。
  88. Max<TSource, TResult>(IEnumerable<TSource>, Func<TSource, TResult>) 调用泛型序列的每个元素的转换函数并返回最大结果值。
  89. Min(IEnumerable<Decimal>) 返回序列中的最小值 Decimal 值。
  90. Min(IEnumerable<Double>) 返回序列中的最小值 Double 值。
  91. Min(IEnumerable<Int32>) 返回序列中的最小值 Int32 值。
  92. Min(IEnumerable<Int64>) 返回序列中的最小值 Int64 值。
  93. Min(IEnumerable<Nullable<Decimal>>) 返回的最小值可以为 null 的序列中 Decimal 值。
  94. Min(IEnumerable<Nullable<Double>>) 返回的最小值可以为 null 的序列中 Double 值。
  95. Min(IEnumerable<Nullable<Int32>>) 返回的最小值可以为 null 的序列中 Int32 值。
  96. Min(IEnumerable<Nullable<Int64>>) 返回的最小值可以为 null 的序列中 Int64 值。
  97. Min(IEnumerable<Nullable<Single>>) 返回的最小值可以为 null 的序列中 Single 值。
  98. Min(IEnumerable<Single>) 返回序列中的最小值 Single 值。
  99. Min<TSource>(IEnumerable<TSource>) 泛型序列中返回的最小值。
  100. Min<TSource>(IEnumerable<TSource>, Func<TSource, Decimal>) 调用转换函数对序列的每个元素,并返回所需的最低 Decimal 值。
  101. Min<TSource>(IEnumerable<TSource>, Func<TSource, Double>) 调用转换函数对序列的每个元素,并返回所需的最低 Double 值。
  102. Min<TSource>(IEnumerable<TSource>, Func<TSource, Int32>) 调用转换函数对序列的每个元素,并返回所需的最低 Int32 值。
  103. Min<TSource>(IEnumerable<TSource>, Func<TSource, Int64>) 调用转换函数对序列的每个元素,并返回所需的最低 Int64 值。
  104. Min<TSource>(IEnumerable<TSource>, Func<TSource, Nullable<Decimal>>) 调用转换函数对序列的每个元素,并返回最小值可以为 null Decimal 值。
  105. Min<TSource>(IEnumerable<TSource>, Func<TSource, Nullable<Double>>) 调用转换函数对序列的每个元素,并返回最小值可以为 null Double 值。
  106. Min<TSource>(IEnumerable<TSource>, Func<TSource, Nullable<Int32>>) 调用转换函数对序列的每个元素,并返回最小值可以为 null Int32 值。
  107. Min<TSource>(IEnumerable<TSource>, Func<TSource, Nullable<Int64>>) 调用转换函数对序列的每个元素,并返回最小值可以为 null Int64 值。
  108. Min<TSource>(IEnumerable<TSource>, Func<TSource, Nullable<Single>>) 调用转换函数对序列的每个元素,并返回最小值可以为 null Single 值。
  109. Min<TSource>(IEnumerable<TSource>, Func<TSource, Single>) 调用转换函数对序列的每个元素,并返回所需的最低 Single 值。
  110. Min<TSource, TResult>(IEnumerable<TSource>, Func<TSource, TResult>) 调用泛型序列的每个元素的转换函数,并返回最小的结果值。
  111. OfType<TResult>(IEnumerable) 筛选的元素 IEnumerable 根据指定的类型。
  112. OrderBy<TSource, TKey>(IEnumerable<TSource>, Func<TSource, TKey>) 按根据某个键按升序对序列的元素进行排序。
  113. OrderBy<TSource, TKey>(IEnumerable<TSource>, Func<TSource, TKey>, IComparer<TKey>) 按使用指定的比较器按升序对序列的元素进行排序。
  114. OrderByDescending<TSource, TKey>(IEnumerable<TSource>, Func<TSource, TKey>) 按根据某个键按降序对序列的元素进行排序。
  115. OrderByDescending<TSource, TKey>(IEnumerable<TSource>, Func<TSource, TKey>, IComparer<TKey>) 使用指定的比较器按降序对序列的元素排序。
  116. Range(Int32, Int32) 生成指定范围内的整数序列。
  117. Repeat<TResult>(TResult, Int32) 将生成一个序列,其中包含一个重复的值。
  118. Reverse<TSource>(IEnumerable<TSource>) 反转序列中元素的顺序。
  119. Select<TSource, TResult>(IEnumerable<TSource>, Func<TSource, TResult>) 将序列中的每个元素投影到新表单。
  120. Select<TSource, TResult>(IEnumerable<TSource>, Func<TSource, Int32, TResult>) 通过合并元素的索引投影到一个新窗体的序列的每个元素。
  121. SelectMany<TSource, TResult>(IEnumerable<TSource>, Func<TSource, IEnumerable<TResult>>) 一个序列的每个元素投影 IEnumerable<T> 并将合并为一个序列将结果序列。
  122. SelectMany<TSource, TResult>(IEnumerable<TSource>, Func<TSource, Int32, IEnumerable<TResult>>) 一个序列的每个元素投影 IEnumerable<T>, ,并将合并为一个序列将结果序列。 每个源元素的索引用于该元素的投影表。
  123. SelectMany<TSource, TCollection, TResult>(IEnumerable<TSource>, Func<TSource, IEnumerable<TCollection>>, Func<TSource, TCollection, TResult>) 一个序列的每个元素投影 IEnumerable<T>, 将平展为一个序列,将结果序列,其中调用结果选择器函数对每个元素。
  124. SelectMany<TSource, TCollection, TResult>(IEnumerable<TSource>, Func<TSource, Int32, IEnumerable<TCollection>>, Func<TSource, TCollection, TResult>) 一个序列的每个元素投影 IEnumerable<T>, 将平展为一个序列,将结果序列,其中调用结果选择器函数对每个元素。 每个源元素的索引用于该元素的中间投影表。
  125. SequenceEqual<TSource>(IEnumerable<TSource>, IEnumerable<TSource>) 确定两个序列是否相等的元素进行比较通过使用相应类型的默认相等比较器。
  126. SequenceEqual<TSource>(IEnumerable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>) 确定两个序列是否通过使用指定的比较它们的元素相等 IEqualityComparer<T>。
  127. Single<TSource>(IEnumerable<TSource>) 返回序列的唯一元素;如果该序列并非恰好包含一个元素,则会引发异常。
  128. Single<TSource>(IEnumerable<TSource>, Func<TSource, Boolean>) 返回序列中满足指定条件的唯一元素;如果有多个这样的元素存在,则会引发异常。
  129. SingleOrDefault<TSource>(IEnumerable<TSource>) 返回一个序列,或默认值的唯一元素,如果序列为空,则为如果序列中存在多个元素,则此方法将引发异常。
  130. SingleOrDefault<TSource>(IEnumerable<TSource>, Func<TSource, Boolean>) 返回序列中满足指定条件的唯一元素;如果这类元素不存在,则返回默认值;如果有多个元素满足该条件,此方法将引发异常。
  131. Skip<TSource>(IEnumerable<TSource>, Int32) 跳过指定的数量的序列中的元素,然后返回剩余元素。
  132. SkipWhile<TSource>(IEnumerable<TSource>, Func<TSource, Boolean>) 只要指定的条件为 true,然后返回剩余元素,跳过序列中的元素。
  133. SkipWhile<TSource>(IEnumerable<TSource>, Func<TSource, Int32, Boolean>) 只要指定的条件为 true,然后返回剩余元素,跳过序列中的元素。 将在谓词函数的逻辑中使用元素的索引。
  134. Sum(IEnumerable<Decimal>) 计算的一系列总和 Decimal 值。
  135. Sum(IEnumerable<Double>) 计算的一系列总和 Double 值。
  136. Sum(IEnumerable<Int32>) 计算的一系列总和 Int32 值。
  137. Sum(IEnumerable<Int64>) 计算的一系列总和 Int64 值。
  138. Sum(IEnumerable<Nullable<Decimal>>) 计算可以为 null 的序列的和 Decimal 值。
  139. Sum(IEnumerable<Nullable<Double>>) 计算可以为 null 的序列的和 Double 值。
  140. Sum(IEnumerable<Nullable<Int32>>) 计算可以为 null 的序列的和 Int32 值。
  141. Sum(IEnumerable<Nullable<Int64>>) 计算可以为 null 的序列的和 Int64 值。
  142. Sum(IEnumerable<Nullable<Single>>) 计算可以为 null 的序列的和 Single 值。
  143. Sum(IEnumerable<Single>) 计算的一系列总和 Single 值。
  144. Sum<TSource>(IEnumerable<TSource>, Func<TSource, Decimal>) 计算的序列的和 Decimal 通过调用对输入序列中的每个元素的转换函数获得的值。
  145. Sum<TSource>(IEnumerable<TSource>, Func<TSource, Double>) 计算的序列的和 Double 通过调用对输入序列中的每个元素的转换函数获得的值。
  146. Sum<TSource>(IEnumerable<TSource>, Func<TSource, Int32>) 计算的序列的和 Int32 通过调用对输入序列中的每个元素的转换函数获得的值。
  147. Sum<TSource>(IEnumerable<TSource>, Func<TSource, Int64>) 计算的序列的和 Int64 通过调用对输入序列中的每个元素的转换函数获得的值。
  148. Sum<TSource>(IEnumerable<TSource>, Func<TSource, Nullable<Decimal>>) 计算可以为 null 的序列的和 Decimal 通过调用对输入序列中的每个元素的转换函数获得的值。
  149. Sum<TSource>(IEnumerable<TSource>, Func<TSource, Nullable<Double>>) 计算可以为 null 的序列的和 Double 通过调用对输入序列中的每个元素的转换函数获得的值。
  150. Sum<TSource>(IEnumerable<TSource>, Func<TSource, Nullable<Int32>>) 计算可以为 null 的序列的和 Int32 通过调用对输入序列中的每个元素的转换函数获得的值。
  151. Sum<TSource>(IEnumerable<TSource>, Func<TSource, Nullable<Int64>>) 计算可以为 null 的序列的和 Int64 通过调用对输入序列中的每个元素的转换函数获得的值。
  152. Sum<TSource>(IEnumerable<TSource>, Func<TSource, Nullable<Single>>) 计算可以为 null 的序列的和 Single 通过调用对输入序列中的每个元素的转换函数获得的值。
  153. Sum<TSource>(IEnumerable<TSource>, Func<TSource, Single>) 计算的序列的和 Single 通过调用对输入序列中的每个元素的转换函数获得的值。
  154. Take<TSource>(IEnumerable<TSource>, Int32) 从序列的开头返回指定的数量的连续元素。
  155. TakeWhile<TSource>(IEnumerable<TSource>, Func<TSource, Boolean>) 返回序列中的元素,只要指定的条件为真。
  156. TakeWhile<TSource>(IEnumerable<TSource>, Func<TSource, Int32, Boolean>) 返回序列中的元素,只要指定的条件为真。 将在谓词函数的逻辑中使用元素的索引。
  157. ThenBy<TSource, TKey>(IOrderedEnumerable<TSource>, Func<TSource, TKey>) 执行后续排序以根据某个键按升序对序列的元素。
  158. ThenBy<TSource, TKey>(IOrderedEnumerable<TSource>, Func<TSource, TKey>, IComparer<TKey>) 执行后续排序中使用指定的比较器按升序对序列的元素。
  159. ThenByDescending<TSource, TKey>(IOrderedEnumerable<TSource>, Func<TSource, TKey>) 根据某个键将执行后续排序顺序,按降序对序列的元素。
  160. ThenByDescending<TSource, TKey>(IOrderedEnumerable<TSource>, Func<TSource, TKey>, IComparer<TKey>) 执行后续排序中使用指定的比较器按降序对序列的元素。
  161. ToArray<TSource>(IEnumerable<TSource>) 创建一个数组,从 IEnumerable<T>。
  162. ToDictionary<TSource, TKey>(IEnumerable<TSource>, Func<TSource, TKey>) 创建 Dictionary<TKey, TValue> 从 IEnumerable<T> 根据指定的键选择器函数。
  163. ToDictionary<TSource, TKey>(IEnumerable<TSource>, Func<TSource, TKey>, IEqualityComparer<TKey>) 创建 Dictionary<TKey, TValue> 从 IEnumerable<T> 根据指定的键选择器函数和键比较器。
  164. ToDictionary<TSource, TKey, TElement>(IEnumerable<TSource>, Func<TSource, TKey>, Func<TSource, TElement>) 创建 Dictionary<TKey, TValue> 从 IEnumerable<T> 根据指定的键选择器和元素选择器函数。
  165. ToDictionary<TSource, TKey, TElement>(IEnumerable<TSource>, Func<TSource, TKey>, Func<TSource, TElement>, IEqualityComparer<TKey>) 创建 Dictionary<TKey, TValue> 从 IEnumerable<T> 根据指定的键选择器函数、 比较器和元素选择器函数。
  166. ToList<TSource>(IEnumerable<TSource>) 创建 List<T> 从 IEnumerable<T>。
  167. ToLookup<TSource, TKey>(IEnumerable<TSource>, Func<TSource, TKey>) 创建 Lookup<TKey, TElement> 从 IEnumerable<T> 根据指定的键选择器函数。
  168. ToLookup<TSource, TKey>(IEnumerable<TSource>, Func<TSource, TKey>, IEqualityComparer<TKey>) 创建 Lookup<TKey, TElement> 从 IEnumerable<T> 根据指定的键选择器函数和键比较器。
  169. ToLookup<TSource, TKey, TElement>(IEnumerable<TSource>, Func<TSource, TKey>, Func<TSource, TElement>) 创建 Lookup<TKey, TElement> 从 IEnumerable<T> 根据指定的键选择器和元素选择器函数。
  170. ToLookup<TSource, TKey, TElement>(IEnumerable<TSource>, Func<TSource, TKey>, Func<TSource, TElement>, IEqualityComparer<TKey>) 创建 Lookup<TKey, TElement> 从 IEnumerable<T> 根据指定的键选择器函数、 比较和元素选择器函数。
  171. Union<TSource>(IEnumerable<TSource>, IEnumerable<TSource>) 通过使用默认的相等比较器生成的两个序列的并集。
  172. Union<TSource>(IEnumerable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>) 使用指定的生成两个序列的并集 IEqualityComparer<T>。
  173. Where<TSource>(IEnumerable<TSource>, Func<TSource, Boolean>) 基于谓词筛选值序列。
  174. Where<TSource>(IEnumerable<TSource>, Func<TSource, Int32, Boolean>) 基于谓词筛选值序列。 将在谓词函数的逻辑中使用每个元素的索引。
  175. Zip<TFirst, TSecond, TResult>(IEnumerable<TFirst>, IEnumerable<TSecond>, Func<TFirst, TSecond, TResult>) 适用于两个序列,生成的结果序列的相应元素指定的函数。

Syntax

namespace System.Linq{
	public static class Enumerable{}
}

Source Code of System.Linq.Enumerable from JetBrains dotPeek 1.0 at 2015-03-09

// Type: System.Linq.Enumerable
// Assembly: System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// Assembly location: C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Core.dll

using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime;
using System.Threading;

namespace System.Linq
{
  [__DynamicallyInvokable]
  public static class Enumerable
  {
    [__DynamicallyInvokable]
    public static IEnumerable<TSource> Where<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      if (predicate == null)
        throw Error.ArgumentNull("predicate");
      if (source is Enumerable.Iterator<TSource>)
        return ((Enumerable.Iterator<TSource>) source).Where(predicate);
      if (source is TSource[])
        return (IEnumerable<TSource>) new Enumerable.WhereArrayIterator<TSource>((TSource[]) source, predicate);
      if (source is List<TSource>)
        return (IEnumerable<TSource>) new Enumerable.WhereListIterator<TSource>((List<TSource>) source, predicate);
      else
        return (IEnumerable<TSource>) new Enumerable.WhereEnumerableIterator<TSource>(source, predicate);
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TSource> Where<TSource>(this IEnumerable<TSource> source, Func<TSource, int, bool> predicate)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      if (predicate == null)
        throw Error.ArgumentNull("predicate");
      else
        return Enumerable.WhereIterator<TSource>(source, predicate);
    }

    private static IEnumerable<TSource> WhereIterator<TSource>(IEnumerable<TSource> source, Func<TSource, int, bool> predicate)
    {
      int index = -1;
      foreach (TSource source1 in source)
      {
        checked { ++index; }
        if (predicate(source1, index))
          yield return source1;
      }
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TResult> Select<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TResult> selector)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      if (selector == null)
        throw Error.ArgumentNull("selector");
      if (source is Enumerable.Iterator<TSource>)
        return ((Enumerable.Iterator<TSource>) source).Select<TResult>(selector);
      if (source is TSource[])
        return (IEnumerable<TResult>) new Enumerable.WhereSelectArrayIterator<TSource, TResult>((TSource[]) source, (Func<TSource, bool>) null, selector);
      if (source is List<TSource>)
        return (IEnumerable<TResult>) new Enumerable.WhereSelectListIterator<TSource, TResult>((List<TSource>) source, (Func<TSource, bool>) null, selector);
      else
        return (IEnumerable<TResult>) new Enumerable.WhereSelectEnumerableIterator<TSource, TResult>(source, (Func<TSource, bool>) null, selector);
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TResult> Select<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, int, TResult> selector)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      if (selector == null)
        throw Error.ArgumentNull("selector");
      else
        return Enumerable.SelectIterator<TSource, TResult>(source, selector);
    }

    private static IEnumerable<TResult> SelectIterator<TSource, TResult>(IEnumerable<TSource> source, Func<TSource, int, TResult> selector)
    {
      int index = -1;
      foreach (TSource source1 in source)
      {
        checked { ++index; }
        yield return selector(source1, index);
      }
    }

    private static Func<TSource, bool> CombinePredicates<TSource>(Func<TSource, bool> predicate1, Func<TSource, bool> predicate2)
    {
      return (Func<TSource, bool>) (x =>
      {
        if (predicate1(x))
          return predicate2(x);
        else
          return false;
      });
    }

    private static Func<TSource, TResult> CombineSelectors<TSource, TMiddle, TResult>(Func<TSource, TMiddle> selector1, Func<TMiddle, TResult> selector2)
    {
      return (Func<TSource, TResult>) (x => selector2(selector1(x)));
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TResult> SelectMany<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, IEnumerable<TResult>> selector)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      if (selector == null)
        throw Error.ArgumentNull("selector");
      else
        return Enumerable.SelectManyIterator<TSource, TResult>(source, selector);
    }

    private static IEnumerable<TResult> SelectManyIterator<TSource, TResult>(IEnumerable<TSource> source, Func<TSource, IEnumerable<TResult>> selector)
    {
      foreach (TSource source1 in source)
      {
        foreach (TResult result in selector(source1))
          yield return result;
      }
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TResult> SelectMany<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, int, IEnumerable<TResult>> selector)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      if (selector == null)
        throw Error.ArgumentNull("selector");
      else
        return Enumerable.SelectManyIterator<TSource, TResult>(source, selector);
    }

    private static IEnumerable<TResult> SelectManyIterator<TSource, TResult>(IEnumerable<TSource> source, Func<TSource, int, IEnumerable<TResult>> selector)
    {
      int index = -1;
      foreach (TSource source1 in source)
      {
        checked { ++index; }
        foreach (TResult result in selector(source1, index))
          yield return result;
      }
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TResult> SelectMany<TSource, TCollection, TResult>(this IEnumerable<TSource> source, Func<TSource, int, IEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      if (collectionSelector == null)
        throw Error.ArgumentNull("collectionSelector");
      if (resultSelector == null)
        throw Error.ArgumentNull("resultSelector");
      else
        return Enumerable.SelectManyIterator<TSource, TCollection, TResult>(source, collectionSelector, resultSelector);
    }

    private static IEnumerable<TResult> SelectManyIterator<TSource, TCollection, TResult>(IEnumerable<TSource> source, Func<TSource, int, IEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)
    {
      int index = -1;
      foreach (TSource source1 in source)
      {
        checked { ++index; }
        foreach (TCollection collection in collectionSelector(source1, index))
          yield return resultSelector(source1, collection);
      }
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TResult> SelectMany<TSource, TCollection, TResult>(this IEnumerable<TSource> source, Func<TSource, IEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      if (collectionSelector == null)
        throw Error.ArgumentNull("collectionSelector");
      if (resultSelector == null)
        throw Error.ArgumentNull("resultSelector");
      else
        return Enumerable.SelectManyIterator<TSource, TCollection, TResult>(source, collectionSelector, resultSelector);
    }

    private static IEnumerable<TResult> SelectManyIterator<TSource, TCollection, TResult>(IEnumerable<TSource> source, Func<TSource, IEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)
    {
      foreach (TSource source1 in source)
      {
        foreach (TCollection collection in collectionSelector(source1))
          yield return resultSelector(source1, collection);
      }
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TSource> Take<TSource>(this IEnumerable<TSource> source, int count)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      else
        return Enumerable.TakeIterator<TSource>(source, count);
    }

    private static IEnumerable<TSource> TakeIterator<TSource>(IEnumerable<TSource> source, int count)
    {
      if (count > 0)
      {
        foreach (TSource source1 in source)
        {
          yield return source1;
          if (--count == 0)
            break;
        }
      }
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TSource> TakeWhile<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      if (predicate == null)
        throw Error.ArgumentNull("predicate");
      else
        return Enumerable.TakeWhileIterator<TSource>(source, predicate);
    }

    private static IEnumerable<TSource> TakeWhileIterator<TSource>(IEnumerable<TSource> source, Func<TSource, bool> predicate)
    {
      foreach (TSource source1 in source)
      {
        if (predicate(source1))
          yield return source1;
        else
          break;
      }
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TSource> TakeWhile<TSource>(this IEnumerable<TSource> source, Func<TSource, int, bool> predicate)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      if (predicate == null)
        throw Error.ArgumentNull("predicate");
      else
        return Enumerable.TakeWhileIterator<TSource>(source, predicate);
    }

    private static IEnumerable<TSource> TakeWhileIterator<TSource>(IEnumerable<TSource> source, Func<TSource, int, bool> predicate)
    {
      int index = -1;
      foreach (TSource source1 in source)
      {
        checked { ++index; }
        if (predicate(source1, index))
          yield return source1;
        else
          break;
      }
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TSource> Skip<TSource>(this IEnumerable<TSource> source, int count)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      else
        return Enumerable.SkipIterator<TSource>(source, count);
    }

    private static IEnumerable<TSource> SkipIterator<TSource>(IEnumerable<TSource> source, int count)
    {
      using (IEnumerator<TSource> enumerator = source.GetEnumerator())
      {
        while (count > 0 && enumerator.MoveNext())
          --count;
        if (count <= 0)
        {
          while (enumerator.MoveNext())
            yield return enumerator.Current;
        }
      }
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TSource> SkipWhile<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      if (predicate == null)
        throw Error.ArgumentNull("predicate");
      else
        return Enumerable.SkipWhileIterator<TSource>(source, predicate);
    }

    private static IEnumerable<TSource> SkipWhileIterator<TSource>(IEnumerable<TSource> source, Func<TSource, bool> predicate)
    {
      bool yielding = false;
      foreach (TSource source1 in source)
      {
        if (!yielding && !predicate(source1))
          yielding = true;
        if (yielding)
          yield return source1;
      }
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TSource> SkipWhile<TSource>(this IEnumerable<TSource> source, Func<TSource, int, bool> predicate)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      if (predicate == null)
        throw Error.ArgumentNull("predicate");
      else
        return Enumerable.SkipWhileIterator<TSource>(source, predicate);
    }

    private static IEnumerable<TSource> SkipWhileIterator<TSource>(IEnumerable<TSource> source, Func<TSource, int, bool> predicate)
    {
      int index = -1;
      bool yielding = false;
      foreach (TSource source1 in source)
      {
        checked { ++index; }
        if (!yielding && !predicate(source1, index))
          yielding = true;
        if (yielding)
          yield return source1;
      }
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TResult> Join<TOuter, TInner, TKey, TResult>(this IEnumerable<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector)
    {
      if (outer == null)
        throw Error.ArgumentNull("outer");
      if (inner == null)
        throw Error.ArgumentNull("inner");
      if (outerKeySelector == null)
        throw Error.ArgumentNull("outerKeySelector");
      if (innerKeySelector == null)
        throw Error.ArgumentNull("innerKeySelector");
      if (resultSelector == null)
        throw Error.ArgumentNull("resultSelector");
      else
        return Enumerable.JoinIterator<TOuter, TInner, TKey, TResult>(outer, inner, outerKeySelector, innerKeySelector, resultSelector, (IEqualityComparer<TKey>) null);
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TResult> Join<TOuter, TInner, TKey, TResult>(this IEnumerable<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector, IEqualityComparer<TKey> comparer)
    {
      if (outer == null)
        throw Error.ArgumentNull("outer");
      if (inner == null)
        throw Error.ArgumentNull("inner");
      if (outerKeySelector == null)
        throw Error.ArgumentNull("outerKeySelector");
      if (innerKeySelector == null)
        throw Error.ArgumentNull("innerKeySelector");
      if (resultSelector == null)
        throw Error.ArgumentNull("resultSelector");
      else
        return Enumerable.JoinIterator<TOuter, TInner, TKey, TResult>(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer);
    }

    private static IEnumerable<TResult> JoinIterator<TOuter, TInner, TKey, TResult>(IEnumerable<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector, IEqualityComparer<TKey> comparer)
    {
      Lookup<TKey, TInner> lookup = Lookup<TKey, TInner>.CreateForJoin(inner, innerKeySelector, comparer);
      foreach (TOuter outer1 in outer)
      {
        Lookup<TKey, TInner>.Grouping g = lookup.GetGrouping(outerKeySelector(outer1), false);
        if (g != null)
        {
          for (int i = 0; i < g.count; ++i)
            yield return resultSelector(outer1, g.elements[i]);
        }
      }
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TResult> GroupJoin<TOuter, TInner, TKey, TResult>(this IEnumerable<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector)
    {
      if (outer == null)
        throw Error.ArgumentNull("outer");
      if (inner == null)
        throw Error.ArgumentNull("inner");
      if (outerKeySelector == null)
        throw Error.ArgumentNull("outerKeySelector");
      if (innerKeySelector == null)
        throw Error.ArgumentNull("innerKeySelector");
      if (resultSelector == null)
        throw Error.ArgumentNull("resultSelector");
      else
        return Enumerable.GroupJoinIterator<TOuter, TInner, TKey, TResult>(outer, inner, outerKeySelector, innerKeySelector, resultSelector, (IEqualityComparer<TKey>) null);
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TResult> GroupJoin<TOuter, TInner, TKey, TResult>(this IEnumerable<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
    {
      if (outer == null)
        throw Error.ArgumentNull("outer");
      if (inner == null)
        throw Error.ArgumentNull("inner");
      if (outerKeySelector == null)
        throw Error.ArgumentNull("outerKeySelector");
      if (innerKeySelector == null)
        throw Error.ArgumentNull("innerKeySelector");
      if (resultSelector == null)
        throw Error.ArgumentNull("resultSelector");
      else
        return Enumerable.GroupJoinIterator<TOuter, TInner, TKey, TResult>(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer);
    }

    private static IEnumerable<TResult> GroupJoinIterator<TOuter, TInner, TKey, TResult>(IEnumerable<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
    {
      Lookup<TKey, TInner> lookup = Lookup<TKey, TInner>.CreateForJoin(inner, innerKeySelector, comparer);
      foreach (TOuter outer1 in outer)
        yield return resultSelector(outer1, lookup[outerKeySelector(outer1)]);
    }

    [__DynamicallyInvokable]
    public static IOrderedEnumerable<TSource> OrderBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
    {
      return (IOrderedEnumerable<TSource>) new OrderedEnumerable<TSource, TKey>(source, keySelector, (IComparer<TKey>) null, false);
    }

    [__DynamicallyInvokable]
    public static IOrderedEnumerable<TSource> OrderBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
    {
      return (IOrderedEnumerable<TSource>) new OrderedEnumerable<TSource, TKey>(source, keySelector, comparer, false);
    }

    [__DynamicallyInvokable]
    public static IOrderedEnumerable<TSource> OrderByDescending<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
    {
      return (IOrderedEnumerable<TSource>) new OrderedEnumerable<TSource, TKey>(source, keySelector, (IComparer<TKey>) null, true);
    }

    [__DynamicallyInvokable]
    public static IOrderedEnumerable<TSource> OrderByDescending<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
    {
      return (IOrderedEnumerable<TSource>) new OrderedEnumerable<TSource, TKey>(source, keySelector, comparer, true);
    }

    [__DynamicallyInvokable]
    public static IOrderedEnumerable<TSource> ThenBy<TSource, TKey>(this IOrderedEnumerable<TSource> source, Func<TSource, TKey> keySelector)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      else
        return source.CreateOrderedEnumerable<TKey>(keySelector, (IComparer<TKey>) null, false);
    }

    [__DynamicallyInvokable]
    public static IOrderedEnumerable<TSource> ThenBy<TSource, TKey>(this IOrderedEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      else
        return source.CreateOrderedEnumerable<TKey>(keySelector, comparer, false);
    }

    [__DynamicallyInvokable]
    public static IOrderedEnumerable<TSource> ThenByDescending<TSource, TKey>(this IOrderedEnumerable<TSource> source, Func<TSource, TKey> keySelector)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      else
        return source.CreateOrderedEnumerable<TKey>(keySelector, (IComparer<TKey>) null, true);
    }

    [__DynamicallyInvokable]
    public static IOrderedEnumerable<TSource> ThenByDescending<TSource, TKey>(this IOrderedEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      else
        return source.CreateOrderedEnumerable<TKey>(keySelector, comparer, true);
    }

    [__DynamicallyInvokable]
    public static IEnumerable<IGrouping<TKey, TSource>> GroupBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
    {
      return (IEnumerable<IGrouping<TKey, TSource>>) new GroupedEnumerable<TSource, TKey, TSource>(source, keySelector, IdentityFunction<TSource>.Instance, (IEqualityComparer<TKey>) null);
    }

    [__DynamicallyInvokable]
    public static IEnumerable<IGrouping<TKey, TSource>> GroupBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
    {
      return (IEnumerable<IGrouping<TKey, TSource>>) new GroupedEnumerable<TSource, TKey, TSource>(source, keySelector, IdentityFunction<TSource>.Instance, comparer);
    }

    [__DynamicallyInvokable]
    public static IEnumerable<IGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
    {
      return (IEnumerable<IGrouping<TKey, TElement>>) new GroupedEnumerable<TSource, TKey, TElement>(source, keySelector, elementSelector, (IEqualityComparer<TKey>) null);
    }

    [__DynamicallyInvokable]
    public static IEnumerable<IGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
    {
      return (IEnumerable<IGrouping<TKey, TElement>>) new GroupedEnumerable<TSource, TKey, TElement>(source, keySelector, elementSelector, comparer);
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TResult> GroupBy<TSource, TKey, TResult>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TKey, IEnumerable<TSource>, TResult> resultSelector)
    {
      return (IEnumerable<TResult>) new GroupedEnumerable<TSource, TKey, TSource, TResult>(source, keySelector, IdentityFunction<TSource>.Instance, resultSelector, (IEqualityComparer<TKey>) null);
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TResult> GroupBy<TSource, TKey, TElement, TResult>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IEnumerable<TElement>, TResult> resultSelector)
    {
      return (IEnumerable<TResult>) new GroupedEnumerable<TSource, TKey, TElement, TResult>(source, keySelector, elementSelector, resultSelector, (IEqualityComparer<TKey>) null);
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TResult> GroupBy<TSource, TKey, TResult>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TKey, IEnumerable<TSource>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
    {
      return (IEnumerable<TResult>) new GroupedEnumerable<TSource, TKey, TSource, TResult>(source, keySelector, IdentityFunction<TSource>.Instance, resultSelector, comparer);
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TResult> GroupBy<TSource, TKey, TElement, TResult>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IEnumerable<TElement>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
    {
      return (IEnumerable<TResult>) new GroupedEnumerable<TSource, TKey, TElement, TResult>(source, keySelector, elementSelector, resultSelector, comparer);
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TSource> Concat<TSource>(this IEnumerable<TSource> first, IEnumerable<TSource> second)
    {
      if (first == null)
        throw Error.ArgumentNull("first");
      if (second == null)
        throw Error.ArgumentNull("second");
      else
        return Enumerable.ConcatIterator<TSource>(first, second);
    }

    private static IEnumerable<TSource> ConcatIterator<TSource>(IEnumerable<TSource> first, IEnumerable<TSource> second)
    {
      foreach (TSource source in first)
        yield return source;
      foreach (TSource source in second)
        yield return source;
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TResult> Zip<TFirst, TSecond, TResult>(this IEnumerable<TFirst> first, IEnumerable<TSecond> second, Func<TFirst, TSecond, TResult> resultSelector)
    {
      if (first == null)
        throw Error.ArgumentNull("first");
      if (second == null)
        throw Error.ArgumentNull("second");
      if (resultSelector == null)
        throw Error.ArgumentNull("resultSelector");
      else
        return Enumerable.ZipIterator<TFirst, TSecond, TResult>(first, second, resultSelector);
    }

    private static IEnumerable<TResult> ZipIterator<TFirst, TSecond, TResult>(IEnumerable<TFirst> first, IEnumerable<TSecond> second, Func<TFirst, TSecond, TResult> resultSelector)
    {
      using (IEnumerator<TFirst> enumerator1 = first.GetEnumerator())
      {
        using (IEnumerator<TSecond> enumerator2 = second.GetEnumerator())
        {
          while (enumerator1.MoveNext() && enumerator2.MoveNext())
            yield return resultSelector(enumerator1.Current, enumerator2.Current);
        }
      }
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TSource> Distinct<TSource>(this IEnumerable<TSource> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      else
        return Enumerable.DistinctIterator<TSource>(source, (IEqualityComparer<TSource>) null);
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TSource> Distinct<TSource>(this IEnumerable<TSource> source, IEqualityComparer<TSource> comparer)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      else
        return Enumerable.DistinctIterator<TSource>(source, comparer);
    }

    private static IEnumerable<TSource> DistinctIterator<TSource>(IEnumerable<TSource> source, IEqualityComparer<TSource> comparer)
    {
      Set<TSource> set = new Set<TSource>(comparer);
      foreach (TSource source1 in source)
      {
        if (set.Add(source1))
          yield return source1;
      }
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TSource> Union<TSource>(this IEnumerable<TSource> first, IEnumerable<TSource> second)
    {
      if (first == null)
        throw Error.ArgumentNull("first");
      if (second == null)
        throw Error.ArgumentNull("second");
      else
        return Enumerable.UnionIterator<TSource>(first, second, (IEqualityComparer<TSource>) null);
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TSource> Union<TSource>(this IEnumerable<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
    {
      if (first == null)
        throw Error.ArgumentNull("first");
      if (second == null)
        throw Error.ArgumentNull("second");
      else
        return Enumerable.UnionIterator<TSource>(first, second, comparer);
    }

    private static IEnumerable<TSource> UnionIterator<TSource>(IEnumerable<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
    {
      Set<TSource> set = new Set<TSource>(comparer);
      foreach (TSource source in first)
      {
        if (set.Add(source))
          yield return source;
      }
      foreach (TSource source in second)
      {
        if (set.Add(source))
          yield return source;
      }
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TSource> Intersect<TSource>(this IEnumerable<TSource> first, IEnumerable<TSource> second)
    {
      if (first == null)
        throw Error.ArgumentNull("first");
      if (second == null)
        throw Error.ArgumentNull("second");
      else
        return Enumerable.IntersectIterator<TSource>(first, second, (IEqualityComparer<TSource>) null);
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TSource> Intersect<TSource>(this IEnumerable<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
    {
      if (first == null)
        throw Error.ArgumentNull("first");
      if (second == null)
        throw Error.ArgumentNull("second");
      else
        return Enumerable.IntersectIterator<TSource>(first, second, comparer);
    }

    private static IEnumerable<TSource> IntersectIterator<TSource>(IEnumerable<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
    {
      Set<TSource> set = new Set<TSource>(comparer);
      foreach (TSource source in second)
        set.Add(source);
      foreach (TSource source in first)
      {
        if (set.Remove(source))
          yield return source;
      }
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TSource> Except<TSource>(this IEnumerable<TSource> first, IEnumerable<TSource> second)
    {
      if (first == null)
        throw Error.ArgumentNull("first");
      if (second == null)
        throw Error.ArgumentNull("second");
      else
        return Enumerable.ExceptIterator<TSource>(first, second, (IEqualityComparer<TSource>) null);
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TSource> Except<TSource>(this IEnumerable<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
    {
      if (first == null)
        throw Error.ArgumentNull("first");
      if (second == null)
        throw Error.ArgumentNull("second");
      else
        return Enumerable.ExceptIterator<TSource>(first, second, comparer);
    }

    private static IEnumerable<TSource> ExceptIterator<TSource>(IEnumerable<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
    {
      Set<TSource> set = new Set<TSource>(comparer);
      foreach (TSource source in second)
        set.Add(source);
      foreach (TSource source in first)
      {
        if (set.Add(source))
          yield return source;
      }
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TSource> Reverse<TSource>(this IEnumerable<TSource> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      else
        return Enumerable.ReverseIterator<TSource>(source);
    }

    private static IEnumerable<TSource> ReverseIterator<TSource>(IEnumerable<TSource> source)
    {
      Buffer<TSource> buffer = new Buffer<TSource>(source);
      for (int i = buffer.count - 1; i >= 0; --i)
        yield return buffer.items[i];
    }

    [__DynamicallyInvokable]
    [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
    public static bool SequenceEqual<TSource>(this IEnumerable<TSource> first, IEnumerable<TSource> second)
    {
      return Enumerable.SequenceEqual<TSource>(first, second, (IEqualityComparer<TSource>) null);
    }

    [__DynamicallyInvokable]
    public static bool SequenceEqual<TSource>(this IEnumerable<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
    {
      if (comparer == null)
        comparer = (IEqualityComparer<TSource>) EqualityComparer<TSource>.Default;
      if (first == null)
        throw Error.ArgumentNull("first");
      if (second == null)
        throw Error.ArgumentNull("second");
      using (IEnumerator<TSource> enumerator1 = first.GetEnumerator())
      {
        using (IEnumerator<TSource> enumerator2 = second.GetEnumerator())
        {
          while (enumerator1.MoveNext())
          {
            if (!enumerator2.MoveNext() || !comparer.Equals(enumerator1.Current, enumerator2.Current))
              return false;
          }
          if (enumerator2.MoveNext())
            return false;
        }
      }
      return true;
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TSource> AsEnumerable<TSource>(this IEnumerable<TSource> source)
    {
      return source;
    }

    [__DynamicallyInvokable]
    public static TSource[] ToArray<TSource>(this IEnumerable<TSource> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      else
        return new Buffer<TSource>(source).ToArray();
    }

    [__DynamicallyInvokable]
    public static List<TSource> ToList<TSource>(this IEnumerable<TSource> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      else
        return new List<TSource>(source);
    }

    [__DynamicallyInvokable]
    public static Dictionary<TKey, TSource> ToDictionary<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
    {
      return Enumerable.ToDictionary<TSource, TKey, TSource>(source, keySelector, IdentityFunction<TSource>.Instance, (IEqualityComparer<TKey>) null);
    }

    [__DynamicallyInvokable]
    public static Dictionary<TKey, TSource> ToDictionary<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
    {
      return Enumerable.ToDictionary<TSource, TKey, TSource>(source, keySelector, IdentityFunction<TSource>.Instance, comparer);
    }

    [__DynamicallyInvokable]
    [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
    public static Dictionary<TKey, TElement> ToDictionary<TSource, TKey, TElement>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
    {
      return Enumerable.ToDictionary<TSource, TKey, TElement>(source, keySelector, elementSelector, (IEqualityComparer<TKey>) null);
    }

    [__DynamicallyInvokable]
    public static Dictionary<TKey, TElement> ToDictionary<TSource, TKey, TElement>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      if (keySelector == null)
        throw Error.ArgumentNull("keySelector");
      if (elementSelector == null)
        throw Error.ArgumentNull("elementSelector");
      Dictionary<TKey, TElement> dictionary = new Dictionary<TKey, TElement>(comparer);
      foreach (TSource source1 in source)
        dictionary.Add(keySelector(source1), elementSelector(source1));
      return dictionary;
    }

    [__DynamicallyInvokable]
    public static ILookup<TKey, TSource> ToLookup<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
    {
      return (ILookup<TKey, TSource>) Lookup<TKey, TSource>.Create<TSource>(source, keySelector, IdentityFunction<TSource>.Instance, (IEqualityComparer<TKey>) null);
    }

    [__DynamicallyInvokable]
    public static ILookup<TKey, TSource> ToLookup<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
    {
      return (ILookup<TKey, TSource>) Lookup<TKey, TSource>.Create<TSource>(source, keySelector, IdentityFunction<TSource>.Instance, comparer);
    }

    [__DynamicallyInvokable]
    public static ILookup<TKey, TElement> ToLookup<TSource, TKey, TElement>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
    {
      return (ILookup<TKey, TElement>) Lookup<TKey, TElement>.Create<TSource>(source, keySelector, elementSelector, (IEqualityComparer<TKey>) null);
    }

    [__DynamicallyInvokable]
    public static ILookup<TKey, TElement> ToLookup<TSource, TKey, TElement>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
    {
      return (ILookup<TKey, TElement>) Lookup<TKey, TElement>.Create<TSource>(source, keySelector, elementSelector, comparer);
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TSource> DefaultIfEmpty<TSource>(this IEnumerable<TSource> source)
    {
      return Enumerable.DefaultIfEmpty<TSource>(source, default (TSource));
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TSource> DefaultIfEmpty<TSource>(this IEnumerable<TSource> source, TSource defaultValue)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      else
        return Enumerable.DefaultIfEmptyIterator<TSource>(source, defaultValue);
    }

    private static IEnumerable<TSource> DefaultIfEmptyIterator<TSource>(IEnumerable<TSource> source, TSource defaultValue)
    {
      using (IEnumerator<TSource> enumerator = source.GetEnumerator())
      {
        if (enumerator.MoveNext())
        {
          do
          {
            yield return enumerator.Current;
          }
          while (enumerator.MoveNext());
        }
        else
          yield return defaultValue;
      }
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TResult> OfType<TResult>(this IEnumerable source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      else
        return Enumerable.OfTypeIterator<TResult>(source);
    }

    private static IEnumerable<TResult> OfTypeIterator<TResult>(IEnumerable source)
    {
      foreach (object obj in source)
      {
        if (obj is TResult)
          yield return (TResult) obj;
      }
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TResult> Cast<TResult>(this IEnumerable source)
    {
      IEnumerable<TResult> enumerable = source as IEnumerable<TResult>;
      if (enumerable != null)
        return enumerable;
      if (source == null)
        throw Error.ArgumentNull("source");
      else
        return Enumerable.CastIterator<TResult>(source);
    }

    private static IEnumerable<TResult> CastIterator<TResult>(IEnumerable source)
    {
      foreach (object obj in source)
        yield return (TResult) obj;
    }

    [__DynamicallyInvokable]
    public static TSource First<TSource>(this IEnumerable<TSource> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      IList<TSource> list = source as IList<TSource>;
      if (list != null)
      {
        if (list.Count > 0)
          return list[0];
      }
      else
      {
        using (IEnumerator<TSource> enumerator = source.GetEnumerator())
        {
          if (enumerator.MoveNext())
            return enumerator.Current;
        }
      }
      throw Error.NoElements();
    }

    [__DynamicallyInvokable]
    public static TSource First<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      if (predicate == null)
        throw Error.ArgumentNull("predicate");
      foreach (TSource source1 in source)
      {
        if (predicate(source1))
          return source1;
      }
      throw Error.NoMatch();
    }

    [__DynamicallyInvokable]
    public static TSource FirstOrDefault<TSource>(this IEnumerable<TSource> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      IList<TSource> list = source as IList<TSource>;
      if (list != null)
      {
        if (list.Count > 0)
          return list[0];
      }
      else
      {
        using (IEnumerator<TSource> enumerator = source.GetEnumerator())
        {
          if (enumerator.MoveNext())
            return enumerator.Current;
        }
      }
      return default (TSource);
    }

    [__DynamicallyInvokable]
    public static TSource FirstOrDefault<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      if (predicate == null)
        throw Error.ArgumentNull("predicate");
      foreach (TSource source1 in source)
      {
        if (predicate(source1))
          return source1;
      }
      return default (TSource);
    }

    [__DynamicallyInvokable]
    public static TSource Last<TSource>(this IEnumerable<TSource> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      IList<TSource> list = source as IList<TSource>;
      if (list != null)
      {
        int count = list.Count;
        if (count > 0)
          return list[count - 1];
      }
      else
      {
        using (IEnumerator<TSource> enumerator = source.GetEnumerator())
        {
          if (enumerator.MoveNext())
          {
            TSource current;
            do
            {
              current = enumerator.Current;
            }
            while (enumerator.MoveNext());
            return current;
          }
        }
      }
      throw Error.NoElements();
    }

    [__DynamicallyInvokable]
    public static TSource Last<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      if (predicate == null)
        throw Error.ArgumentNull("predicate");
      TSource source1 = default (TSource);
      bool flag = false;
      foreach (TSource source2 in source)
      {
        if (predicate(source2))
        {
          source1 = source2;
          flag = true;
        }
      }
      if (flag)
        return source1;
      else
        throw Error.NoMatch();
    }

    [__DynamicallyInvokable]
    public static TSource LastOrDefault<TSource>(this IEnumerable<TSource> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      IList<TSource> list = source as IList<TSource>;
      if (list != null)
      {
        int count = list.Count;
        if (count > 0)
          return list[count - 1];
      }
      else
      {
        using (IEnumerator<TSource> enumerator = source.GetEnumerator())
        {
          if (enumerator.MoveNext())
          {
            TSource current;
            do
            {
              current = enumerator.Current;
            }
            while (enumerator.MoveNext());
            return current;
          }
        }
      }
      return default (TSource);
    }

    [__DynamicallyInvokable]
    public static TSource LastOrDefault<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      if (predicate == null)
        throw Error.ArgumentNull("predicate");
      TSource source1 = default (TSource);
      foreach (TSource source2 in source)
      {
        if (predicate(source2))
          source1 = source2;
      }
      return source1;
    }

    [__DynamicallyInvokable]
    public static TSource Single<TSource>(this IEnumerable<TSource> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      IList<TSource> list = source as IList<TSource>;
      if (list != null)
      {
        switch (list.Count)
        {
          case 0:
            throw Error.NoElements();
          case 1:
            return list[0];
        }
      }
      else
      {
        using (IEnumerator<TSource> enumerator = source.GetEnumerator())
        {
          if (!enumerator.MoveNext())
            throw Error.NoElements();
          TSource current = enumerator.Current;
          if (!enumerator.MoveNext())
            return current;
        }
      }
      throw Error.MoreThanOneElement();
    }

    [__DynamicallyInvokable]
    public static TSource Single<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      if (predicate == null)
        throw Error.ArgumentNull("predicate");
      TSource source1 = default (TSource);
      long num = 0L;
      foreach (TSource source2 in source)
      {
        if (predicate(source2))
        {
          source1 = source2;
          checked { ++num; }
        }
      }
      switch (num)
      {
        case 0L:
          throw Error.NoMatch();
        case 1L:
          return source1;
        default:
          throw Error.MoreThanOneMatch();
      }
    }

    [__DynamicallyInvokable]
    public static TSource SingleOrDefault<TSource>(this IEnumerable<TSource> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      IList<TSource> list = source as IList<TSource>;
      if (list != null)
      {
        switch (list.Count)
        {
          case 0:
            return default (TSource);
          case 1:
            return list[0];
        }
      }
      else
      {
        using (IEnumerator<TSource> enumerator = source.GetEnumerator())
        {
          if (!enumerator.MoveNext())
            return default (TSource);
          TSource current = enumerator.Current;
          if (!enumerator.MoveNext())
            return current;
        }
      }
      throw Error.MoreThanOneElement();
    }

    [__DynamicallyInvokable]
    public static TSource SingleOrDefault<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      if (predicate == null)
        throw Error.ArgumentNull("predicate");
      TSource source1 = default (TSource);
      long num = 0L;
      foreach (TSource source2 in source)
      {
        if (predicate(source2))
        {
          source1 = source2;
          checked { ++num; }
        }
      }
      switch (num)
      {
        case 0L:
          return default (TSource);
        case 1L:
          return source1;
        default:
          throw Error.MoreThanOneMatch();
      }
    }

    [__DynamicallyInvokable]
    public static TSource ElementAt<TSource>(this IEnumerable<TSource> source, int index)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      IList<TSource> list = source as IList<TSource>;
      if (list != null)
        return list[index];
      if (index < 0)
        throw Error.ArgumentOutOfRange("index");
      using (IEnumerator<TSource> enumerator = source.GetEnumerator())
      {
        while (enumerator.MoveNext())
        {
          if (index == 0)
            return enumerator.Current;
          --index;
        }
        throw Error.ArgumentOutOfRange("index");
      }
    }

    [__DynamicallyInvokable]
    public static TSource ElementAtOrDefault<TSource>(this IEnumerable<TSource> source, int index)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      if (index >= 0)
      {
        IList<TSource> list = source as IList<TSource>;
        if (list != null)
        {
          if (index < list.Count)
            return list[index];
        }
        else
        {
          foreach (TSource source1 in source)
          {
            if (index == 0)
              return source1;
            --index;
          }
        }
      }
      return default (TSource);
    }

    [__DynamicallyInvokable]
    public static IEnumerable<int> Range(int start, int count)
    {
      long num = (long) start + (long) count - 1L;
      if (count < 0 || num > (long) int.MaxValue)
        throw Error.ArgumentOutOfRange("count");
      else
        return Enumerable.RangeIterator(start, count);
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TResult> Repeat<TResult>(TResult element, int count)
    {
      if (count < 0)
        throw Error.ArgumentOutOfRange("count");
      else
        return Enumerable.RepeatIterator<TResult>(element, count);
    }

    private static IEnumerable<TResult> RepeatIterator<TResult>(TResult element, int count)
    {
      for (int i = 0; i < count; ++i)
        yield return element;
    }

    [__DynamicallyInvokable]
    public static IEnumerable<TResult> Empty<TResult>()
    {
      return EmptyEnumerable<TResult>.Instance;
    }

    [__DynamicallyInvokable]
    public static bool Any<TSource>(this IEnumerable<TSource> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      using (IEnumerator<TSource> enumerator = source.GetEnumerator())
      {
        if (enumerator.MoveNext())
          return true;
      }
      return false;
    }

    [__DynamicallyInvokable]
    public static bool Any<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      if (predicate == null)
        throw Error.ArgumentNull("predicate");
      foreach (TSource source1 in source)
      {
        if (predicate(source1))
          return true;
      }
      return false;
    }

    [__DynamicallyInvokable]
    public static bool All<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      if (predicate == null)
        throw Error.ArgumentNull("predicate");
      foreach (TSource source1 in source)
      {
        if (!predicate(source1))
          return false;
      }
      return true;
    }

    [__DynamicallyInvokable]
    public static int Count<TSource>(this IEnumerable<TSource> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      ICollection<TSource> collection1 = source as ICollection<TSource>;
      if (collection1 != null)
        return collection1.Count;
      ICollection collection2 = source as ICollection;
      if (collection2 != null)
        return collection2.Count;
      int num = 0;
      using (IEnumerator<TSource> enumerator = source.GetEnumerator())
      {
        while (enumerator.MoveNext())
          checked { ++num; }
      }
      return num;
    }

    [__DynamicallyInvokable]
    public static int Count<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      if (predicate == null)
        throw Error.ArgumentNull("predicate");
      int num = 0;
      foreach (TSource source1 in source)
      {
        if (predicate(source1))
          checked { ++num; }
      }
      return num;
    }

    [__DynamicallyInvokable]
    public static long LongCount<TSource>(this IEnumerable<TSource> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      long num = 0L;
      using (IEnumerator<TSource> enumerator = source.GetEnumerator())
      {
        while (enumerator.MoveNext())
          checked { ++num; }
      }
      return num;
    }

    [__DynamicallyInvokable]
    public static long LongCount<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      if (predicate == null)
        throw Error.ArgumentNull("predicate");
      long num = 0L;
      foreach (TSource source1 in source)
      {
        if (predicate(source1))
          checked { ++num; }
      }
      return num;
    }

    [__DynamicallyInvokable]
    public static bool Contains<TSource>(this IEnumerable<TSource> source, TSource value)
    {
      ICollection<TSource> collection = source as ICollection<TSource>;
      if (collection != null)
        return collection.Contains(value);
      else
        return Enumerable.Contains<TSource>(source, value, (IEqualityComparer<TSource>) null);
    }

    [__DynamicallyInvokable]
    public static bool Contains<TSource>(this IEnumerable<TSource> source, TSource value, IEqualityComparer<TSource> comparer)
    {
      if (comparer == null)
        comparer = (IEqualityComparer<TSource>) EqualityComparer<TSource>.Default;
      if (source == null)
        throw Error.ArgumentNull("source");
      foreach (TSource x in source)
      {
        if (comparer.Equals(x, value))
          return true;
      }
      return false;
    }

    [__DynamicallyInvokable]
    public static TSource Aggregate<TSource>(this IEnumerable<TSource> source, Func<TSource, TSource, TSource> func)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      if (func == null)
        throw Error.ArgumentNull("func");
      using (IEnumerator<TSource> enumerator = source.GetEnumerator())
      {
        if (!enumerator.MoveNext())
          throw Error.NoElements();
        TSource source1 = enumerator.Current;
        while (enumerator.MoveNext())
          source1 = func(source1, enumerator.Current);
        return source1;
      }
    }

    [__DynamicallyInvokable]
    public static TAccumulate Aggregate<TSource, TAccumulate>(this IEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      if (func == null)
        throw Error.ArgumentNull("func");
      TAccumulate accumulate = seed;
      foreach (TSource source1 in source)
        accumulate = func(accumulate, source1);
      return accumulate;
    }

    [__DynamicallyInvokable]
    public static TResult Aggregate<TSource, TAccumulate, TResult>(this IEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func, Func<TAccumulate, TResult> resultSelector)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      if (func == null)
        throw Error.ArgumentNull("func");
      if (resultSelector == null)
        throw Error.ArgumentNull("resultSelector");
      TAccumulate accumulate = seed;
      foreach (TSource source1 in source)
        accumulate = func(accumulate, source1);
      return resultSelector(accumulate);
    }

    [__DynamicallyInvokable]
    public static int Sum(this IEnumerable<int> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      int num1 = 0;
      foreach (int num2 in source)
        checked { num1 += num2; }
      return num1;
    }

    [__DynamicallyInvokable]
    public static int? Sum(this IEnumerable<int?> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      int num = 0;
      foreach (int? nullable in source)
      {
        if (nullable.HasValue)
          checked { num += nullable.GetValueOrDefault(); }
      }
      return new int?(num);
    }

    [__DynamicallyInvokable]
    public static long Sum(this IEnumerable<long> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      long num1 = 0L;
      foreach (long num2 in source)
        checked { num1 += num2; }
      return num1;
    }

    [__DynamicallyInvokable]
    public static long? Sum(this IEnumerable<long?> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      long num = 0L;
      foreach (long? nullable in source)
      {
        if (nullable.HasValue)
          checked { num += nullable.GetValueOrDefault(); }
      }
      return new long?(num);
    }

    [__DynamicallyInvokable]
    public static float Sum(this IEnumerable<float> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      double num1 = 0.0;
      foreach (float num2 in source)
        num1 += (double) num2;
      return (float) num1;
    }

    [__DynamicallyInvokable]
    public static float? Sum(this IEnumerable<float?> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      double num = 0.0;
      foreach (float? nullable in source)
      {
        if (nullable.HasValue)
          num += (double) nullable.GetValueOrDefault();
      }
      return new float?((float) num);
    }

    [__DynamicallyInvokable]
    public static double Sum(this IEnumerable<double> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      double num1 = 0.0;
      foreach (double num2 in source)
        num1 += num2;
      return num1;
    }

    [__DynamicallyInvokable]
    public static double? Sum(this IEnumerable<double?> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      double num = 0.0;
      foreach (double? nullable in source)
      {
        if (nullable.HasValue)
          num += nullable.GetValueOrDefault();
      }
      return new double?(num);
    }

    [__DynamicallyInvokable]
    public static Decimal Sum(this IEnumerable<Decimal> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      Decimal num1 = new Decimal(0);
      foreach (Decimal num2 in source)
        num1 += num2;
      return num1;
    }

    [__DynamicallyInvokable]
    public static Decimal? Sum(this IEnumerable<Decimal?> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      Decimal num = new Decimal(0);
      foreach (Decimal? nullable in source)
      {
        if (nullable.HasValue)
          num += nullable.GetValueOrDefault();
      }
      return new Decimal?(num);
    }

    [__DynamicallyInvokable]
    public static int Sum<TSource>(this IEnumerable<TSource> source, Func<TSource, int> selector)
    {
      return Enumerable.Sum(Enumerable.Select<TSource, int>(source, selector));
    }

    [__DynamicallyInvokable]
    public static int? Sum<TSource>(this IEnumerable<TSource> source, Func<TSource, int?> selector)
    {
      return Enumerable.Sum(Enumerable.Select<TSource, int?>(source, selector));
    }

    [__DynamicallyInvokable]
    public static long Sum<TSource>(this IEnumerable<TSource> source, Func<TSource, long> selector)
    {
      return Enumerable.Sum(Enumerable.Select<TSource, long>(source, selector));
    }

    [__DynamicallyInvokable]
    public static long? Sum<TSource>(this IEnumerable<TSource> source, Func<TSource, long?> selector)
    {
      return Enumerable.Sum(Enumerable.Select<TSource, long?>(source, selector));
    }

    [__DynamicallyInvokable]
    public static float Sum<TSource>(this IEnumerable<TSource> source, Func<TSource, float> selector)
    {
      return Enumerable.Sum(Enumerable.Select<TSource, float>(source, selector));
    }

    [__DynamicallyInvokable]
    public static float? Sum<TSource>(this IEnumerable<TSource> source, Func<TSource, float?> selector)
    {
      return Enumerable.Sum(Enumerable.Select<TSource, float?>(source, selector));
    }

    [__DynamicallyInvokable]
    public static double Sum<TSource>(this IEnumerable<TSource> source, Func<TSource, double> selector)
    {
      return Enumerable.Sum(Enumerable.Select<TSource, double>(source, selector));
    }

    [__DynamicallyInvokable]
    public static double? Sum<TSource>(this IEnumerable<TSource> source, Func<TSource, double?> selector)
    {
      return Enumerable.Sum(Enumerable.Select<TSource, double?>(source, selector));
    }

    [__DynamicallyInvokable]
    public static Decimal Sum<TSource>(this IEnumerable<TSource> source, Func<TSource, Decimal> selector)
    {
      return Enumerable.Sum(Enumerable.Select<TSource, Decimal>(source, selector));
    }

    [__DynamicallyInvokable]
    public static Decimal? Sum<TSource>(this IEnumerable<TSource> source, Func<TSource, Decimal?> selector)
    {
      return Enumerable.Sum(Enumerable.Select<TSource, Decimal?>(source, selector));
    }

    [__DynamicallyInvokable]
    public static int Min(this IEnumerable<int> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      int num1 = 0;
      bool flag = false;
      foreach (int num2 in source)
      {
        if (flag)
        {
          if (num2 < num1)
            num1 = num2;
        }
        else
        {
          num1 = num2;
          flag = true;
        }
      }
      if (flag)
        return num1;
      else
        throw Error.NoElements();
    }

    [__DynamicallyInvokable]
    public static int? Min(this IEnumerable<int?> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      int? nullable1 = new int?();
      foreach (int? nullable2 in source)
      {
        if (nullable1.HasValue)
        {
          int? nullable3 = nullable2;
          int? nullable4 = nullable1;
          if ((nullable3.GetValueOrDefault() >= nullable4.GetValueOrDefault() ? 0 : (nullable3.HasValue & nullable4.HasValue ? 1 : 0)) == 0)
            continue;
        }
        nullable1 = nullable2;
      }
      return nullable1;
    }

    [__DynamicallyInvokable]
    public static long Min(this IEnumerable<long> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      long num1 = 0L;
      bool flag = false;
      foreach (long num2 in source)
      {
        if (flag)
        {
          if (num2 < num1)
            num1 = num2;
        }
        else
        {
          num1 = num2;
          flag = true;
        }
      }
      if (flag)
        return num1;
      else
        throw Error.NoElements();
    }

    [__DynamicallyInvokable]
    public static long? Min(this IEnumerable<long?> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      long? nullable1 = new long?();
      foreach (long? nullable2 in source)
      {
        if (nullable1.HasValue)
        {
          long? nullable3 = nullable2;
          long? nullable4 = nullable1;
          if ((nullable3.GetValueOrDefault() >= nullable4.GetValueOrDefault() ? 0 : (nullable3.HasValue & nullable4.HasValue ? 1 : 0)) == 0)
            continue;
        }
        nullable1 = nullable2;
      }
      return nullable1;
    }

    [__DynamicallyInvokable]
    public static float Min(this IEnumerable<float> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      float num = 0.0f;
      bool flag = false;
      foreach (float f in source)
      {
        if (flag)
        {
          if ((double) f < (double) num || float.IsNaN(f))
            num = f;
        }
        else
        {
          num = f;
          flag = true;
        }
      }
      if (flag)
        return num;
      else
        throw Error.NoElements();
    }

    [__DynamicallyInvokable]
    public static float? Min(this IEnumerable<float?> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      float? nullable1 = new float?();
      foreach (float? nullable2 in source)
      {
        if (nullable2.HasValue)
        {
          if (nullable1.HasValue)
          {
            float? nullable3 = nullable2;
            float? nullable4 = nullable1;
            if (((double) nullable3.GetValueOrDefault() >= (double) nullable4.GetValueOrDefault() ? 0 : (nullable3.HasValue & nullable4.HasValue ? 1 : 0)) == 0 && !float.IsNaN(nullable2.Value))
              continue;
          }
          nullable1 = nullable2;
        }
      }
      return nullable1;
    }

    [__DynamicallyInvokable]
    public static double Min(this IEnumerable<double> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      double num = 0.0;
      bool flag = false;
      foreach (double d in source)
      {
        if (flag)
        {
          if (d < num || double.IsNaN(d))
            num = d;
        }
        else
        {
          num = d;
          flag = true;
        }
      }
      if (flag)
        return num;
      else
        throw Error.NoElements();
    }

    [__DynamicallyInvokable]
    public static double? Min(this IEnumerable<double?> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      double? nullable1 = new double?();
      foreach (double? nullable2 in source)
      {
        if (nullable2.HasValue)
        {
          if (nullable1.HasValue)
          {
            double? nullable3 = nullable2;
            double? nullable4 = nullable1;
            if ((nullable3.GetValueOrDefault() >= nullable4.GetValueOrDefault() ? 0 : (nullable3.HasValue & nullable4.HasValue ? 1 : 0)) == 0 && !double.IsNaN(nullable2.Value))
              continue;
          }
          nullable1 = nullable2;
        }
      }
      return nullable1;
    }

    [__DynamicallyInvokable]
    public static Decimal Min(this IEnumerable<Decimal> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      Decimal num1 = new Decimal(0);
      bool flag = false;
      foreach (Decimal num2 in source)
      {
        if (flag)
        {
          if (num2 < num1)
            num1 = num2;
        }
        else
        {
          num1 = num2;
          flag = true;
        }
      }
      if (flag)
        return num1;
      else
        throw Error.NoElements();
    }

    [__DynamicallyInvokable]
    public static Decimal? Min(this IEnumerable<Decimal?> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      Decimal? nullable1 = new Decimal?();
      foreach (Decimal? nullable2 in source)
      {
        if (nullable1.HasValue)
        {
          Decimal? nullable3 = nullable2;
          Decimal? nullable4 = nullable1;
          if ((!(nullable3.GetValueOrDefault() < nullable4.GetValueOrDefault()) ? 0 : (nullable3.HasValue & nullable4.HasValue ? 1 : 0)) == 0)
            continue;
        }
        nullable1 = nullable2;
      }
      return nullable1;
    }

    [__DynamicallyInvokable]
    public static TSource Min<TSource>(this IEnumerable<TSource> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      Comparer<TSource> @default = Comparer<TSource>.Default;
      TSource y = default (TSource);
      if ((object) y == null)
      {
        foreach (TSource x in source)
        {
          if ((object) x != null && ((object) y == null || @default.Compare(x, y) < 0))
            y = x;
        }
        return y;
      }
      else
      {
        bool flag = false;
        foreach (TSource x in source)
        {
          if (flag)
          {
            if (@default.Compare(x, y) < 0)
              y = x;
          }
          else
          {
            y = x;
            flag = true;
          }
        }
        if (flag)
          return y;
        else
          throw Error.NoElements();
      }
    }

    [__DynamicallyInvokable]
    public static int Min<TSource>(this IEnumerable<TSource> source, Func<TSource, int> selector)
    {
      return Enumerable.Min(Enumerable.Select<TSource, int>(source, selector));
    }

    [__DynamicallyInvokable]
    public static int? Min<TSource>(this IEnumerable<TSource> source, Func<TSource, int?> selector)
    {
      return Enumerable.Min(Enumerable.Select<TSource, int?>(source, selector));
    }

    [__DynamicallyInvokable]
    public static long Min<TSource>(this IEnumerable<TSource> source, Func<TSource, long> selector)
    {
      return Enumerable.Min(Enumerable.Select<TSource, long>(source, selector));
    }

    [__DynamicallyInvokable]
    public static long? Min<TSource>(this IEnumerable<TSource> source, Func<TSource, long?> selector)
    {
      return Enumerable.Min(Enumerable.Select<TSource, long?>(source, selector));
    }

    [__DynamicallyInvokable]
    public static float Min<TSource>(this IEnumerable<TSource> source, Func<TSource, float> selector)
    {
      return Enumerable.Min(Enumerable.Select<TSource, float>(source, selector));
    }

    [__DynamicallyInvokable]
    public static float? Min<TSource>(this IEnumerable<TSource> source, Func<TSource, float?> selector)
    {
      return Enumerable.Min(Enumerable.Select<TSource, float?>(source, selector));
    }

    [__DynamicallyInvokable]
    public static double Min<TSource>(this IEnumerable<TSource> source, Func<TSource, double> selector)
    {
      return Enumerable.Min(Enumerable.Select<TSource, double>(source, selector));
    }

    [__DynamicallyInvokable]
    public static double? Min<TSource>(this IEnumerable<TSource> source, Func<TSource, double?> selector)
    {
      return Enumerable.Min(Enumerable.Select<TSource, double?>(source, selector));
    }

    [__DynamicallyInvokable]
    public static Decimal Min<TSource>(this IEnumerable<TSource> source, Func<TSource, Decimal> selector)
    {
      return Enumerable.Min(Enumerable.Select<TSource, Decimal>(source, selector));
    }

    [__DynamicallyInvokable]
    public static Decimal? Min<TSource>(this IEnumerable<TSource> source, Func<TSource, Decimal?> selector)
    {
      return Enumerable.Min(Enumerable.Select<TSource, Decimal?>(source, selector));
    }

    [__DynamicallyInvokable]
    public static TResult Min<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TResult> selector)
    {
      return Enumerable.Min<TResult>(Enumerable.Select<TSource, TResult>(source, selector));
    }

    [__DynamicallyInvokable]
    public static int Max(this IEnumerable<int> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      int num1 = 0;
      bool flag = false;
      foreach (int num2 in source)
      {
        if (flag)
        {
          if (num2 > num1)
            num1 = num2;
        }
        else
        {
          num1 = num2;
          flag = true;
        }
      }
      if (flag)
        return num1;
      else
        throw Error.NoElements();
    }

    [__DynamicallyInvokable]
    public static int? Max(this IEnumerable<int?> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      int? nullable1 = new int?();
      foreach (int? nullable2 in source)
      {
        if (nullable1.HasValue)
        {
          int? nullable3 = nullable2;
          int? nullable4 = nullable1;
          if ((nullable3.GetValueOrDefault() <= nullable4.GetValueOrDefault() ? 0 : (nullable3.HasValue & nullable4.HasValue ? 1 : 0)) == 0)
            continue;
        }
        nullable1 = nullable2;
      }
      return nullable1;
    }

    [__DynamicallyInvokable]
    public static long Max(this IEnumerable<long> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      long num1 = 0L;
      bool flag = false;
      foreach (long num2 in source)
      {
        if (flag)
        {
          if (num2 > num1)
            num1 = num2;
        }
        else
        {
          num1 = num2;
          flag = true;
        }
      }
      if (flag)
        return num1;
      else
        throw Error.NoElements();
    }

    [__DynamicallyInvokable]
    public static long? Max(this IEnumerable<long?> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      long? nullable1 = new long?();
      foreach (long? nullable2 in source)
      {
        if (nullable1.HasValue)
        {
          long? nullable3 = nullable2;
          long? nullable4 = nullable1;
          if ((nullable3.GetValueOrDefault() <= nullable4.GetValueOrDefault() ? 0 : (nullable3.HasValue & nullable4.HasValue ? 1 : 0)) == 0)
            continue;
        }
        nullable1 = nullable2;
      }
      return nullable1;
    }

    [__DynamicallyInvokable]
    public static double Max(this IEnumerable<double> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      double d = 0.0;
      bool flag = false;
      foreach (double num in source)
      {
        if (flag)
        {
          if (num > d || double.IsNaN(d))
            d = num;
        }
        else
        {
          d = num;
          flag = true;
        }
      }
      if (flag)
        return d;
      else
        throw Error.NoElements();
    }

    [__DynamicallyInvokable]
    public static double? Max(this IEnumerable<double?> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      double? nullable1 = new double?();
      foreach (double? nullable2 in source)
      {
        if (nullable2.HasValue)
        {
          if (nullable1.HasValue)
          {
            double? nullable3 = nullable2;
            double? nullable4 = nullable1;
            if ((nullable3.GetValueOrDefault() <= nullable4.GetValueOrDefault() ? 0 : (nullable3.HasValue & nullable4.HasValue ? 1 : 0)) == 0 && !double.IsNaN(nullable1.Value))
              continue;
          }
          nullable1 = nullable2;
        }
      }
      return nullable1;
    }

    [__DynamicallyInvokable]
    public static float Max(this IEnumerable<float> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      float num1 = 0.0f;
      bool flag = false;
      foreach (float num2 in source)
      {
        if (flag)
        {
          if ((double) num2 > (double) num1 || double.IsNaN((double) num1))
            num1 = num2;
        }
        else
        {
          num1 = num2;
          flag = true;
        }
      }
      if (flag)
        return num1;
      else
        throw Error.NoElements();
    }

    [__DynamicallyInvokable]
    public static float? Max(this IEnumerable<float?> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      float? nullable1 = new float?();
      foreach (float? nullable2 in source)
      {
        if (nullable2.HasValue)
        {
          if (nullable1.HasValue)
          {
            float? nullable3 = nullable2;
            float? nullable4 = nullable1;
            if (((double) nullable3.GetValueOrDefault() <= (double) nullable4.GetValueOrDefault() ? 0 : (nullable3.HasValue & nullable4.HasValue ? 1 : 0)) == 0 && !float.IsNaN(nullable1.Value))
              continue;
          }
          nullable1 = nullable2;
        }
      }
      return nullable1;
    }

    [__DynamicallyInvokable]
    public static Decimal Max(this IEnumerable<Decimal> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      Decimal num1 = new Decimal(0);
      bool flag = false;
      foreach (Decimal num2 in source)
      {
        if (flag)
        {
          if (num2 > num1)
            num1 = num2;
        }
        else
        {
          num1 = num2;
          flag = true;
        }
      }
      if (flag)
        return num1;
      else
        throw Error.NoElements();
    }

    [__DynamicallyInvokable]
    public static Decimal? Max(this IEnumerable<Decimal?> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      Decimal? nullable1 = new Decimal?();
      foreach (Decimal? nullable2 in source)
      {
        if (nullable1.HasValue)
        {
          Decimal? nullable3 = nullable2;
          Decimal? nullable4 = nullable1;
          if ((!(nullable3.GetValueOrDefault() > nullable4.GetValueOrDefault()) ? 0 : (nullable3.HasValue & nullable4.HasValue ? 1 : 0)) == 0)
            continue;
        }
        nullable1 = nullable2;
      }
      return nullable1;
    }

    [__DynamicallyInvokable]
    public static TSource Max<TSource>(this IEnumerable<TSource> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      Comparer<TSource> @default = Comparer<TSource>.Default;
      TSource y = default (TSource);
      if ((object) y == null)
      {
        foreach (TSource x in source)
        {
          if ((object) x != null && ((object) y == null || @default.Compare(x, y) > 0))
            y = x;
        }
        return y;
      }
      else
      {
        bool flag = false;
        foreach (TSource x in source)
        {
          if (flag)
          {
            if (@default.Compare(x, y) > 0)
              y = x;
          }
          else
          {
            y = x;
            flag = true;
          }
        }
        if (flag)
          return y;
        else
          throw Error.NoElements();
      }
    }

    [__DynamicallyInvokable]
    public static int Max<TSource>(this IEnumerable<TSource> source, Func<TSource, int> selector)
    {
      return Enumerable.Max(Enumerable.Select<TSource, int>(source, selector));
    }

    [__DynamicallyInvokable]
    public static int? Max<TSource>(this IEnumerable<TSource> source, Func<TSource, int?> selector)
    {
      return Enumerable.Max(Enumerable.Select<TSource, int?>(source, selector));
    }

    [__DynamicallyInvokable]
    public static long Max<TSource>(this IEnumerable<TSource> source, Func<TSource, long> selector)
    {
      return Enumerable.Max(Enumerable.Select<TSource, long>(source, selector));
    }

    [__DynamicallyInvokable]
    public static long? Max<TSource>(this IEnumerable<TSource> source, Func<TSource, long?> selector)
    {
      return Enumerable.Max(Enumerable.Select<TSource, long?>(source, selector));
    }

    [__DynamicallyInvokable]
    public static float Max<TSource>(this IEnumerable<TSource> source, Func<TSource, float> selector)
    {
      return Enumerable.Max(Enumerable.Select<TSource, float>(source, selector));
    }

    [__DynamicallyInvokable]
    public static float? Max<TSource>(this IEnumerable<TSource> source, Func<TSource, float?> selector)
    {
      return Enumerable.Max(Enumerable.Select<TSource, float?>(source, selector));
    }

    [__DynamicallyInvokable]
    public static double Max<TSource>(this IEnumerable<TSource> source, Func<TSource, double> selector)
    {
      return Enumerable.Max(Enumerable.Select<TSource, double>(source, selector));
    }

    [__DynamicallyInvokable]
    public static double? Max<TSource>(this IEnumerable<TSource> source, Func<TSource, double?> selector)
    {
      return Enumerable.Max(Enumerable.Select<TSource, double?>(source, selector));
    }

    [__DynamicallyInvokable]
    public static Decimal Max<TSource>(this IEnumerable<TSource> source, Func<TSource, Decimal> selector)
    {
      return Enumerable.Max(Enumerable.Select<TSource, Decimal>(source, selector));
    }

    [__DynamicallyInvokable]
    public static Decimal? Max<TSource>(this IEnumerable<TSource> source, Func<TSource, Decimal?> selector)
    {
      return Enumerable.Max(Enumerable.Select<TSource, Decimal?>(source, selector));
    }

    [__DynamicallyInvokable]
    public static TResult Max<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TResult> selector)
    {
      return Enumerable.Max<TResult>(Enumerable.Select<TSource, TResult>(source, selector));
    }

    [__DynamicallyInvokable]
    public static double Average(this IEnumerable<int> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      long num1 = 0L;
      long num2 = 0L;
      foreach (int num3 in source)
      {
        checked { num1 += (long) num3; }
        checked { ++num2; }
      }
      if (num2 > 0L)
        return (double) num1 / (double) num2;
      else
        throw Error.NoElements();
    }

    [__DynamicallyInvokable]
    public static double? Average(this IEnumerable<int?> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      long num1 = 0L;
      long num2 = 0L;
      foreach (int? nullable in source)
      {
        if (nullable.HasValue)
        {
          checked { num1 += (long) nullable.GetValueOrDefault(); }
          checked { ++num2; }
        }
      }
      if (num2 > 0L)
        return new double?((double) num1 / (double) num2);
      else
        return new double?();
    }

    [__DynamicallyInvokable]
    public static double Average(this IEnumerable<long> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      long num1 = 0L;
      long num2 = 0L;
      foreach (long num3 in source)
      {
        checked { num1 += num3; }
        checked { ++num2; }
      }
      if (num2 > 0L)
        return (double) num1 / (double) num2;
      else
        throw Error.NoElements();
    }

    [__DynamicallyInvokable]
    public static double? Average(this IEnumerable<long?> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      long num1 = 0L;
      long num2 = 0L;
      foreach (long? nullable in source)
      {
        if (nullable.HasValue)
        {
          checked { num1 += nullable.GetValueOrDefault(); }
          checked { ++num2; }
        }
      }
      if (num2 > 0L)
        return new double?((double) num1 / (double) num2);
      else
        return new double?();
    }

    [__DynamicallyInvokable]
    public static float Average(this IEnumerable<float> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      double num1 = 0.0;
      long num2 = 0L;
      foreach (float num3 in source)
      {
        num1 += (double) num3;
        checked { ++num2; }
      }
      if (num2 > 0L)
        return (float) num1 / (float) num2;
      else
        throw Error.NoElements();
    }

    [__DynamicallyInvokable]
    public static float? Average(this IEnumerable<float?> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      double num1 = 0.0;
      long num2 = 0L;
      foreach (float? nullable in source)
      {
        if (nullable.HasValue)
        {
          num1 += (double) nullable.GetValueOrDefault();
          checked { ++num2; }
        }
      }
      if (num2 > 0L)
        return new float?((float) num1 / (float) num2);
      else
        return new float?();
    }

    [__DynamicallyInvokable]
    public static double Average(this IEnumerable<double> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      double num1 = 0.0;
      long num2 = 0L;
      foreach (double num3 in source)
      {
        num1 += num3;
        checked { ++num2; }
      }
      if (num2 > 0L)
        return num1 / (double) num2;
      else
        throw Error.NoElements();
    }

    [__DynamicallyInvokable]
    public static double? Average(this IEnumerable<double?> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      double num1 = 0.0;
      long num2 = 0L;
      foreach (double? nullable in source)
      {
        if (nullable.HasValue)
        {
          num1 += nullable.GetValueOrDefault();
          checked { ++num2; }
        }
      }
      if (num2 > 0L)
        return new double?(num1 / (double) num2);
      else
        return new double?();
    }

    [__DynamicallyInvokable]
    public static Decimal Average(this IEnumerable<Decimal> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      Decimal num1 = new Decimal(0);
      long num2 = 0L;
      foreach (Decimal num3 in source)
      {
        num1 += num3;
        checked { ++num2; }
      }
      if (num2 > 0L)
        return num1 / (Decimal) num2;
      else
        throw Error.NoElements();
    }

    [__DynamicallyInvokable]
    public static Decimal? Average(this IEnumerable<Decimal?> source)
    {
      if (source == null)
        throw Error.ArgumentNull("source");
      Decimal num1 = new Decimal(0);
      long num2 = 0L;
      foreach (Decimal? nullable in source)
      {
        if (nullable.HasValue)
        {
          num1 += nullable.GetValueOrDefault();
          checked { ++num2; }
        }
      }
      if (num2 > 0L)
        return new Decimal?(num1 / (Decimal) num2);
      else
        return new Decimal?();
    }

    [__DynamicallyInvokable]
    public static double Average<TSource>(this IEnumerable<TSource> source, Func<TSource, int> selector)
    {
      return Enumerable.Average(Enumerable.Select<TSource, int>(source, selector));
    }

    [__DynamicallyInvokable]
    public static double? Average<TSource>(this IEnumerable<TSource> source, Func<TSource, int?> selector)
    {
      return Enumerable.Average(Enumerable.Select<TSource, int?>(source, selector));
    }

    [__DynamicallyInvokable]
    public static double Average<TSource>(this IEnumerable<TSource> source, Func<TSource, long> selector)
    {
      return Enumerable.Average(Enumerable.Select<TSource, long>(source, selector));
    }

    [__DynamicallyInvokable]
    public static double? Average<TSource>(this IEnumerable<TSource> source, Func<TSource, long?> selector)
    {
      return Enumerable.Average(Enumerable.Select<TSource, long?>(source, selector));
    }

    [__DynamicallyInvokable]
    public static float Average<TSource>(this IEnumerable<TSource> source, Func<TSource, float> selector)
    {
      return Enumerable.Average(Enumerable.Select<TSource, float>(source, selector));
    }

    [__DynamicallyInvokable]
    public static float? Average<TSource>(this IEnumerable<TSource> source, Func<TSource, float?> selector)
    {
      return Enumerable.Average(Enumerable.Select<TSource, float?>(source, selector));
    }

    [__DynamicallyInvokable]
    public static double Average<TSource>(this IEnumerable<TSource> source, Func<TSource, double> selector)
    {
      return Enumerable.Average(Enumerable.Select<TSource, double>(source, selector));
    }

    [__DynamicallyInvokable]
    public static double? Average<TSource>(this IEnumerable<TSource> source, Func<TSource, double?> selector)
    {
      return Enumerable.Average(Enumerable.Select<TSource, double?>(source, selector));
    }

    [__DynamicallyInvokable]
    public static Decimal Average<TSource>(this IEnumerable<TSource> source, Func<TSource, Decimal> selector)
    {
      return Enumerable.Average(Enumerable.Select<TSource, Decimal>(source, selector));
    }

    [__DynamicallyInvokable]
    public static Decimal? Average<TSource>(this IEnumerable<TSource> source, Func<TSource, Decimal?> selector)
    {
      return Enumerable.Average(Enumerable.Select<TSource, Decimal?>(source, selector));
    }

    private static IEnumerable<int> RangeIterator(int start, int count)
    {
      for (int i = 0; i < count; ++i)
        yield return start + i;
    }

    private abstract class Iterator<TSource> : IEnumerable<TSource>, IEnumerable, IEnumerator<TSource>, IDisposable, IEnumerator
    {
      private int threadId;
      internal int state;
      internal TSource current;

      public TSource Current
      {
        [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] get
        {
          return this.current;
        }
      }

      object IEnumerator.Current
      {
        get
        {
          return (object) this.Current;
        }
      }

      public Iterator()
      {
        this.threadId = Thread.CurrentThread.ManagedThreadId;
      }

      public abstract Enumerable.Iterator<TSource> Clone();

      public virtual void Dispose()
      {
        this.current = default (TSource);
        this.state = -1;
      }

      public IEnumerator<TSource> GetEnumerator()
      {
        if (this.threadId == Thread.CurrentThread.ManagedThreadId && this.state == 0)
        {
          this.state = 1;
          return (IEnumerator<TSource>) this;
        }
        else
        {
          Enumerable.Iterator<TSource> iterator = this.Clone();
          iterator.state = 1;
          return (IEnumerator<TSource>) iterator;
        }
      }

      public abstract bool MoveNext();

      public abstract IEnumerable<TResult> Select<TResult>(Func<TSource, TResult> selector);

      public abstract IEnumerable<TSource> Where(Func<TSource, bool> predicate);

      [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
      IEnumerator IEnumerable.GetEnumerator()
      {
        return (IEnumerator) this.GetEnumerator();
      }

      void IEnumerator.Reset()
      {
        throw new NotImplementedException();
      }
    }

    private class WhereEnumerableIterator<TSource> : Enumerable.Iterator<TSource>
    {
      private IEnumerable<TSource> source;
      private Func<TSource, bool> predicate;
      private IEnumerator<TSource> enumerator;

      [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
      public WhereEnumerableIterator(IEnumerable<TSource> source, Func<TSource, bool> predicate)
      {
        this.source = source;
        this.predicate = predicate;
      }

      public override Enumerable.Iterator<TSource> Clone()
      {
        return (Enumerable.Iterator<TSource>) new Enumerable.WhereEnumerableIterator<TSource>(this.source, this.predicate);
      }

      public override void Dispose()
      {
        if (this.enumerator != null)
          this.enumerator.Dispose();
        this.enumerator = (IEnumerator<TSource>) null;
        base.Dispose();
      }

      public override bool MoveNext()
      {
        switch (this.state)
        {
          case 1:
            this.enumerator = this.source.GetEnumerator();
            this.state = 2;
            goto case 2;
          case 2:
            while (this.enumerator.MoveNext())
            {
              TSource current = this.enumerator.Current;
              if (this.predicate(current))
              {
                this.current = current;
                return true;
              }
            }
            this.Dispose();
            break;
        }
        return false;
      }

      public override IEnumerable<TResult> Select<TResult>(Func<TSource, TResult> selector)
      {
        return (IEnumerable<TResult>) new Enumerable.WhereSelectEnumerableIterator<TSource, TResult>(this.source, this.predicate, selector);
      }

      public override IEnumerable<TSource> Where(Func<TSource, bool> predicate)
      {
        return (IEnumerable<TSource>) new Enumerable.WhereEnumerableIterator<TSource>(this.source, Enumerable.CombinePredicates<TSource>(this.predicate, predicate));
      }
    }

    private class WhereArrayIterator<TSource> : Enumerable.Iterator<TSource>
    {
      private TSource[] source;
      private Func<TSource, bool> predicate;
      private int index;

      [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
      public WhereArrayIterator(TSource[] source, Func<TSource, bool> predicate)
      {
        this.source = source;
        this.predicate = predicate;
      }

      public override Enumerable.Iterator<TSource> Clone()
      {
        return (Enumerable.Iterator<TSource>) new Enumerable.WhereArrayIterator<TSource>(this.source, this.predicate);
      }

      public override bool MoveNext()
      {
        if (this.state == 1)
        {
          while (this.index < this.source.Length)
          {
            TSource source = this.source[this.index];
            ++this.index;
            if (this.predicate(source))
            {
              this.current = source;
              return true;
            }
          }
          this.Dispose();
        }
        return false;
      }

      public override IEnumerable<TResult> Select<TResult>(Func<TSource, TResult> selector)
      {
        return (IEnumerable<TResult>) new Enumerable.WhereSelectArrayIterator<TSource, TResult>(this.source, this.predicate, selector);
      }

      public override IEnumerable<TSource> Where(Func<TSource, bool> predicate)
      {
        return (IEnumerable<TSource>) new Enumerable.WhereArrayIterator<TSource>(this.source, Enumerable.CombinePredicates<TSource>(this.predicate, predicate));
      }
    }

    private class WhereListIterator<TSource> : Enumerable.Iterator<TSource>
    {
      private List<TSource> source;
      private Func<TSource, bool> predicate;
      private List<TSource>.Enumerator enumerator;

      [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
      public WhereListIterator(List<TSource> source, Func<TSource, bool> predicate)
      {
        this.source = source;
        this.predicate = predicate;
      }

      public override Enumerable.Iterator<TSource> Clone()
      {
        return (Enumerable.Iterator<TSource>) new Enumerable.WhereListIterator<TSource>(this.source, this.predicate);
      }

      public override bool MoveNext()
      {
        switch (this.state)
        {
          case 1:
            this.enumerator = this.source.GetEnumerator();
            this.state = 2;
            goto case 2;
          case 2:
            while (this.enumerator.MoveNext())
            {
              TSource current = this.enumerator.Current;
              if (this.predicate(current))
              {
                this.current = current;
                return true;
              }
            }
            this.Dispose();
            break;
        }
        return false;
      }

      public override IEnumerable<TResult> Select<TResult>(Func<TSource, TResult> selector)
      {
        return (IEnumerable<TResult>) new Enumerable.WhereSelectListIterator<TSource, TResult>(this.source, this.predicate, selector);
      }

      public override IEnumerable<TSource> Where(Func<TSource, bool> predicate)
      {
        return (IEnumerable<TSource>) new Enumerable.WhereListIterator<TSource>(this.source, Enumerable.CombinePredicates<TSource>(this.predicate, predicate));
      }
    }

    private class WhereSelectEnumerableIterator<TSource, TResult> : Enumerable.Iterator<TResult>
    {
      private IEnumerable<TSource> source;
      private Func<TSource, bool> predicate;
      private Func<TSource, TResult> selector;
      private IEnumerator<TSource> enumerator;

      [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
      public WhereSelectEnumerableIterator(IEnumerable<TSource> source, Func<TSource, bool> predicate, Func<TSource, TResult> selector)
      {
        this.source = source;
        this.predicate = predicate;
        this.selector = selector;
      }

      public override Enumerable.Iterator<TResult> Clone()
      {
        return (Enumerable.Iterator<TResult>) new Enumerable.WhereSelectEnumerableIterator<TSource, TResult>(this.source, this.predicate, this.selector);
      }

      public override void Dispose()
      {
        if (this.enumerator != null)
          this.enumerator.Dispose();
        this.enumerator = (IEnumerator<TSource>) null;
        base.Dispose();
      }

      public override bool MoveNext()
      {
        switch (this.state)
        {
          case 1:
            this.enumerator = this.source.GetEnumerator();
            this.state = 2;
            goto case 2;
          case 2:
            while (this.enumerator.MoveNext())
            {
              TSource current = this.enumerator.Current;
              if (this.predicate == null || this.predicate(current))
              {
                this.current = this.selector(current);
                return true;
              }
            }
            this.Dispose();
            break;
        }
        return false;
      }

      public override IEnumerable<TResult2> Select<TResult2>(Func<TResult, TResult2> selector)
      {
        return (IEnumerable<TResult2>) new Enumerable.WhereSelectEnumerableIterator<TSource, TResult2>(this.source, this.predicate, Enumerable.CombineSelectors<TSource, TResult, TResult2>(this.selector, selector));
      }

      public override IEnumerable<TResult> Where(Func<TResult, bool> predicate)
      {
        return (IEnumerable<TResult>) new Enumerable.WhereEnumerableIterator<TResult>((IEnumerable<TResult>) this, predicate);
      }
    }

    private class WhereSelectArrayIterator<TSource, TResult> : Enumerable.Iterator<TResult>
    {
      private TSource[] source;
      private Func<TSource, bool> predicate;
      private Func<TSource, TResult> selector;
      private int index;

      [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
      public WhereSelectArrayIterator(TSource[] source, Func<TSource, bool> predicate, Func<TSource, TResult> selector)
      {
        this.source = source;
        this.predicate = predicate;
        this.selector = selector;
      }

      public override Enumerable.Iterator<TResult> Clone()
      {
        return (Enumerable.Iterator<TResult>) new Enumerable.WhereSelectArrayIterator<TSource, TResult>(this.source, this.predicate, this.selector);
      }

      public override bool MoveNext()
      {
        if (this.state == 1)
        {
          while (this.index < this.source.Length)
          {
            TSource source = this.source[this.index];
            ++this.index;
            if (this.predicate == null || this.predicate(source))
            {
              this.current = this.selector(source);
              return true;
            }
          }
          this.Dispose();
        }
        return false;
      }

      public override IEnumerable<TResult2> Select<TResult2>(Func<TResult, TResult2> selector)
      {
        return (IEnumerable<TResult2>) new Enumerable.WhereSelectArrayIterator<TSource, TResult2>(this.source, this.predicate, Enumerable.CombineSelectors<TSource, TResult, TResult2>(this.selector, selector));
      }

      public override IEnumerable<TResult> Where(Func<TResult, bool> predicate)
      {
        return (IEnumerable<TResult>) new Enumerable.WhereEnumerableIterator<TResult>((IEnumerable<TResult>) this, predicate);
      }
    }

    private class WhereSelectListIterator<TSource, TResult> : Enumerable.Iterator<TResult>
    {
      private List<TSource> source;
      private Func<TSource, bool> predicate;
      private Func<TSource, TResult> selector;
      private List<TSource>.Enumerator enumerator;

      [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
      public WhereSelectListIterator(List<TSource> source, Func<TSource, bool> predicate, Func<TSource, TResult> selector)
      {
        this.source = source;
        this.predicate = predicate;
        this.selector = selector;
      }

      public override Enumerable.Iterator<TResult> Clone()
      {
        return (Enumerable.Iterator<TResult>) new Enumerable.WhereSelectListIterator<TSource, TResult>(this.source, this.predicate, this.selector);
      }

      public override bool MoveNext()
      {
        switch (this.state)
        {
          case 1:
            this.enumerator = this.source.GetEnumerator();
            this.state = 2;
            goto case 2;
          case 2:
            while (this.enumerator.MoveNext())
            {
              TSource current = this.enumerator.Current;
              if (this.predicate == null || this.predicate(current))
              {
                this.current = this.selector(current);
                return true;
              }
            }
            this.Dispose();
            break;
        }
        return false;
      }

      public override IEnumerable<TResult2> Select<TResult2>(Func<TResult, TResult2> selector)
      {
        return (IEnumerable<TResult2>) new Enumerable.WhereSelectListIterator<TSource, TResult2>(this.source, this.predicate, Enumerable.CombineSelectors<TSource, TResult, TResult2>(this.selector, selector));
      }

      public override IEnumerable<TResult> Where(Func<TResult, bool> predicate)
      {
        return (IEnumerable<TResult>) new Enumerable.WhereEnumerableIterator<TResult>((IEnumerable<TResult>) this, predicate);
      }
    }
  }
}

Statistics

该类中全部都是 public static 方法。统计如下:

约 110 个方法第 1 个参数都是:
this IEnumerable<TSource> source

Average()、Max()、Min()、Sum(),它们的重载中,各有 10 个重载 第 1 个参数 分别如下:
this IEnumerable<decimal?> source
this IEnumerable<decimal> source
this IEnumerable<double?> source
this IEnumerable<double> source
this IEnumerable<float?> source
this IEnumerable<float> source
this IEnumerable<int?> source
this IEnumerable<int> source
this IEnumerable<long?> source
this IEnumerable<long> source

以下 2 个方法无重载:
public static IEnumerable<TResult> Cast<TResult>(this IEnumerable source);
public static IEnumerable<TResult> OfType<TResult>(this IEnumerable source);

与排序相关的共以下 8 个方法,这 8 个方法返回值类型均为 IOrderedEnumerable<TSource>。
其中正序与逆序各 2 个重载,这 4 个方法第 1 个参数均为 this IEnumerable<TSource> source。
public static IOrderedEnumerable<TSource> OrderBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector);
public static IOrderedEnumerable<TSource> OrderBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer);
public static IOrderedEnumerable<TSource> OrderByDescending<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector);
public static IOrderedEnumerable<TSource> OrderByDescending<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer);
其中正序与逆序的后续排序各 2 个重载,这 4 个方法第 1 个参数均为 this IOrderedEnumerable<TSource> source,因此这 4 个方法只能在上述 4 个 OrderBy()之后被调用:
public static IOrderedEnumerable<TSource> ThenBy<TSource, TKey>(this IOrderedEnumerable<TSource> source, Func<TSource, TKey> keySelector);
public static IOrderedEnumerable<TSource> ThenBy<TSource, TKey>(this IOrderedEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer);
public static IOrderedEnumerable<TSource> ThenByDescending<TSource, TKey>(this IOrderedEnumerable<TSource> source, Func<TSource, TKey> keySelector);
public static IOrderedEnumerable<TSource> ThenByDescending<TSource, TKey>(this IOrderedEnumerable<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer);

以下 3 个方法没有重载,且第 1 个参数无 this 修饰符,不是扩展方法,详见本站专文:
public static IEnumerable<TResult> Empty<TResult>();
public static IEnumerable<int> Range(int start, int count);
public static IEnumerable<TResult> Repeat<TResult>(TResult element, int count);