ImmutableArray<T> 结构

定义

表示不可变的数组;这意味着,该数组在创建后不可更改。

NuGet package: System.Collections.Immutable关于不可变集合和安装方法

generic <typename T>
public value class ImmutableArray : IEquatable<System::Collections::Immutable::ImmutableArray<T>>, System::Collections::Generic::ICollection<T>, System::Collections::Generic::IEnumerable<T>, System::Collections::Generic::IList<T>, System::Collections::Generic::IReadOnlyCollection<T>, System::Collections::Generic::IReadOnlyList<T>, System::Collections::IList, System::Collections::Immutable::IImmutableList<T>, System::Collections::IStructuralComparable, System::Collections::IStructuralEquatable
public struct ImmutableArray<T> : IEquatable<System.Collections.Immutable.ImmutableArray<T>>, System.Collections.Generic.ICollection<T>, System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IList<T>, System.Collections.Generic.IReadOnlyCollection<T>, System.Collections.Generic.IReadOnlyList<T>, System.Collections.IList, System.Collections.Immutable.IImmutableList<T>, System.Collections.IStructuralComparable, System.Collections.IStructuralEquatable
public readonly struct ImmutableArray<T> : IEquatable<System.Collections.Immutable.ImmutableArray<T>>, System.Collections.Generic.ICollection<T>, System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IList<T>, System.Collections.Generic.IReadOnlyCollection<T>, System.Collections.Generic.IReadOnlyList<T>, System.Collections.IList, System.Collections.Immutable.IImmutableList<T>, System.Collections.IStructuralComparable, System.Collections.IStructuralEquatable
type ImmutableArray<'T> = struct
    interface IReadOnlyList<'T>
    interface IReadOnlyCollection<'T>
    interface seq<'T>
    interface IEnumerable
    interface IList<'T>
    interface ICollection<'T>
    interface IImmutableList<'T>
    interface IList
    interface ICollection
type ImmutableArray<'T> = struct
    interface ICollection<'T>
    interface seq<'T>
    interface IEnumerable
    interface IList<'T>
    interface IReadOnlyCollection<'T>
    interface IReadOnlyList<'T>
    interface ICollection
    interface IList
    interface IImmutableList<'T>
Public Structure ImmutableArray(Of T)
Implements ICollection(Of T), IEnumerable(Of T), IEquatable(Of ImmutableArray(Of T)), IImmutableList(Of T), IList, IList(Of T), IReadOnlyCollection(Of T), IReadOnlyList(Of T), IStructuralComparable, IStructuralEquatable

类型参数

T

数组存储的元素的类型。

继承
ImmutableArray<T>
实现

示例

此示例演示如何创建不可变数组并循环访问其中元素:

// Create an immutable array of numbers
ImmutableArray<int> numbers = ImmutableArray.Create(1, 2, 3, 4, -1, -2);

// Iterate over all items in the array and print them
foreach (int n in numbers)
{
    Console.Write(n);
    Console.Write(' ');
}
// Output: 1 2 3 4 -1 -2

此示例演示如何通过添加和删除原始数组中的项来创建新的不可变数组:

ImmutableArray<int> numbers2 = numbers.RemoveAt(0).Add(-3);
// numbers2 will contain: 2 3 4 -1 -2 -3

此示例演示如何使用 ImmutableArray<T>.Builder创建不可变数组:

// Create immutable array builder
ImmutableArray<int>.Builder builder = ImmutableArray.CreateBuilder<int>();

// Iterate over all items in the original array and add positive elements to the builder
for (int i = 0; i < numbers.Length; i++)
{
    if (numbers[i] > 0) builder.Add(numbers[i]);
}

// Create an immutable array from the contents of the builder
ImmutableArray<int> numbers3 = builder.ToImmutable();
// numbers3 will contain: 1 2 3 4

注解

有一些方案最适合 ImmutableArray<T> ,而其他方案最适合 ImmutableList<T>

使用不可变数组的原因:

  • 更新数据的情况很少见,或者元素数非常少 (少于 16 项)

  • 你需要能够循环访问性能关键部分中的数据

  • 有许多不可变集合的实例,并且无法承受将数据保留在树中

使用不可变列表的原因:

  • 更新数据很常见,或者元素数预计不会少

  • 更新集合比循环访问内容更关键于性能

下表总结了 ImmutableArray<T>

操作 ImmutableArray<T> 复杂性 ImmutableList<T> 复杂性 注释
Item O(1) O (日志 n) 直接索引到基础数组
Add() O (n) O (日志 n) 需要创建新数组

字段

Empty

获取空的不可变数组。

属性

IsDefault

获取一个值,该值指示此数组是否已声明但未初始化。

IsDefaultOrEmpty

获取一个值,该值指示此 ImmutableArray<T> 是否为空或未初始化。

IsEmpty

获取一个值,该值指示此 ImmutableArray<T> 是否为空。

Item[Int32]

获取位于不可变数组中指定索引处的元素。

Length

获取数组中的元素数。

方法

Add(T)

返回末尾添加了指定项的原始数组的副本。

AddRange(IEnumerable<T>)

返回原始数组的副本,该数组的末尾添加了指定项。

AddRange(ImmutableArray<T>)

返回原始数组的副本,该数组的末尾添加了指定项。

AddRange(ImmutableArray<T>, Int32)

将指定项添加到数组的末尾。

AddRange(ReadOnlySpan<T>)

将指定的值添加到此列表。

AddRange(T[])

将指定的值添加到此列表。

AddRange(T[], Int32)

将指定项添加到数组的末尾。

AddRange<TDerived>(ImmutableArray<TDerived>)

将指定项添加到数组的末尾。

AddRange<TDerived>(TDerived[])

将指定项添加到数组的末尾。

As<TOther>()

返回一个新的不可变数组,其中包含此数组的已转换成不同类型的元素。

AsMemory()

通过此不可变数组创建新的只读内存区域。

AsSpan()

通过此不可变数组创建新的只读范围。

AsSpan(Int32, Int32)

在当前 ImmutableArray<T>的部分上创建 ,ReadOnlySpan<T>从指定长度的指定位置开始。

AsSpan(Range)

基于指定的 range创建当前ImmutableArray<T>部分的跨度。

CastArray<TOther>()

通过将基础数组转换为 TOther 类型的数组,初始化 ImmutableArray<T> 结构的新实例。

CastUp<TDerived>(ImmutableArray<TDerived>)

基于现有实例的内容,初始化 ImmutableArray<T> 结构的新实例,允许协变静态转换,以便高效重用现有数组。

Clear()

返回已移除所有元素的数组。

Contains(T)

确定指定的项是否存在于数组中。

Contains(T, IEqualityComparer<T>)

确定指定的项是否存在于数组中。

CopyTo(Int32, T[], Int32, Int32)

将此数组中的指定项复制到指定数组中的指定起始索引处。

CopyTo(Span<T>)

将当前 ImmutableArray<T> 元素复制到 Span<T>

CopyTo(T[])

将此数组的内容复制到指定的数组。

CopyTo(T[], Int32)

从指定目标索引处开始,将此数组的内容复制到指定的数组。

Equals(ImmutableArray<T>)

指示指定的数组是否等于此数组。

Equals(Object)

确定此数组是否等于指定的对象。

GetEnumerator()

返回循环访问数组内容的枚举器。

GetHashCode()

返回此实例的哈希代码。

IndexOf(T)

搜索指定项的数组。

IndexOf(T, Int32)

搜索指定项的数组。

IndexOf(T, Int32, IEqualityComparer<T>)

搜索指定项的数组。

IndexOf(T, Int32, Int32)

搜索指定项的数组。

IndexOf(T, Int32, Int32, IEqualityComparer<T>)

搜索指定项的数组。

Insert(Int32, T)

返回一个新数组,指定的值已插入到该数组的指定位置。

InsertRange(Int32, IEnumerable<T>)

在指定索引处插入指定的值。

InsertRange(Int32, ImmutableArray<T>)

在指定索引处插入指定的值。

InsertRange(Int32, ReadOnlySpan<T>)

在指定索引处插入指定的值。

InsertRange(Int32, T[])

在指定索引处插入指定的值。

ItemRef(Int32)

获取对位于只读列表中指定 index 处的元素的只读索引。

LastIndexOf(T)

搜索指定项的数组;从该数组的末尾处开始。

LastIndexOf(T, Int32)

搜索指定项的数组;从该数组的末尾处开始。

LastIndexOf(T, Int32, Int32)

搜索指定项的数组;从该数组的末尾处开始。

LastIndexOf(T, Int32, Int32, IEqualityComparer<T>)

搜索指定项的数组;从该数组的末尾处开始。

OfType<TResult>()

筛选此数组的元素,以仅显示可分配给指定类型的元素。

Remove(T)

返回一个数组,其中包含已从数组中移除的指定元素的第一个匹配项。 如果未找到匹配项,则返回当前的数组。

Remove(T, IEqualityComparer<T>)

返回一个数组,其中包含已从数组中移除的指定元素的第一个匹配项。

如果未找到匹配项,则返回当前的数组。

RemoveAll(Predicate<T>)

从数组中移除满足指定条件的所有项。

RemoveAt(Int32)

返回一个数组,其中位于指定位置的元素已被移除。

RemoveRange(IEnumerable<T>)

从此数组中移除指定的项。

RemoveRange(IEnumerable<T>, IEqualityComparer<T>)

从此数组中移除指定的项。

RemoveRange(ImmutableArray<T>)

从此列表中移除指定的值。

RemoveRange(ImmutableArray<T>, IEqualityComparer<T>)

从此列表中移除指定的项。

RemoveRange(Int32, Int32)

返回一个数组,其中位于指定位置的元素已被移除。

RemoveRange(ReadOnlySpan<T>, IEqualityComparer<T>)

从此列表中移除指定的值。

RemoveRange(T[], IEqualityComparer<T>)

从此列表中移除指定的值。

Replace(T, T)

查找数组中与指定值相等的第一个元素,并将该值替换为指定的新值。

Replace(T, T, IEqualityComparer<T>)

查找数组中与指定值相等的第一个元素,并将该值替换为指定的新值。

SetItem(Int32, T)

使用指定项替换指定索引处的项。

Slice(Int32, Int32)

从指定长度的指定索引处开始,形成当前 ImmutableArray<T> 切片。

Sort()

使用默认比较器对不可变数组中的元素进行排序。

Sort(Comparison<T>)

使用指定的 Comparison<T>,对整个 ImmutableArray<T> 中的元素进行排序。

Sort(IComparer<T>)

使用指定的比较器对不可变数组中的元素进行排序。

Sort(Int32, Int32, IComparer<T>)

使用指定的比较器对不可变数组中的指定元素进行排序。

ToBuilder()

创建一个其内容与此数组相同,并且可使用标准可变接口在多个操作之间有效转变的不可变数组。

运算符

Equality(ImmutableArray<T>, ImmutableArray<T>)

返回一个值,该值指示两个数组是否相等。

Equality(Nullable<ImmutableArray<T>>, Nullable<ImmutableArray<T>>)

返回一个值,该值指示两个数组是否相等。

Inequality(ImmutableArray<T>, ImmutableArray<T>)

返回一个值,该值指示两个数组是否不相等。

Inequality(Nullable<ImmutableArray<T>>, Nullable<ImmutableArray<T>>)

检查两个数组是否不相等。

显式接口实现

ICollection.CopyTo(Array, Int32)

从指定的索引开始,将此数组复制到另一个数组。

ICollection.Count

获取数组的大小。

ICollection.IsSynchronized

请参阅 ICollection 接口。 始终返回 true,因为不可变集合是线程安全的。

ICollection.SyncRoot

获取同步根目录。

ICollection<T>.Add(T)

在所有情况下均引发 NotSupportedException

ICollection<T>.Clear()

在所有情况下均引发 NotSupportedException

ICollection<T>.Count

获取集合中的项数。

ICollection<T>.IsReadOnly

获取一个值,该值指示此实例是否为只读。

ICollection<T>.Remove(T)

在所有情况下均引发 NotSupportedException

IEnumerable.GetEnumerator()

返回一个循环访问不可变数组的枚举器。

IEnumerable<T>.GetEnumerator()

返回循环访问数组的枚举器。

IImmutableList<T>.Add(T)

返回末尾添加了指定项的原始数组的副本。

IImmutableList<T>.AddRange(IEnumerable<T>)

返回原始数组的副本,该数组的末尾添加了指定项。

IImmutableList<T>.Clear()

返回已移除所有元素的数组。

IImmutableList<T>.Insert(Int32, T)

返回一个新数组,指定的值已插入到该数组的指定位置。

IImmutableList<T>.InsertRange(Int32, IEnumerable<T>)

在指定索引处插入指定的值。

IImmutableList<T>.Remove(T, IEqualityComparer<T>)

返回一个数组,其中包含已从数组中移除的指定元素的第一个匹配项;如果未找到匹配项,则返回当前数组。

IImmutableList<T>.RemoveAll(Predicate<T>)

从数组中移除满足指定条件的所有项。

IImmutableList<T>.RemoveAt(Int32)

返回一个数组,其中位于指定位置的元素已被移除。

IImmutableList<T>.RemoveRange(IEnumerable<T>, IEqualityComparer<T>)

从此数组中移除指定的项。

IImmutableList<T>.RemoveRange(Int32, Int32)

返回一个数组,其中位于指定位置的元素已被移除。

IImmutableList<T>.Replace(T, T, IEqualityComparer<T>)

查找数组中与指定值相等的第一个元素,并将该值替换为指定的新值。

IImmutableList<T>.SetItem(Int32, T)

使用指定项替换指定索引处的项。

IList.Add(Object)

在所有情况下均引发 NotSupportedException

IList.Clear()

在所有情况下均引发 NotSupportedException

IList.Contains(Object)

在所有情况下均引发 NotSupportedException

IList.IndexOf(Object)

获取位于指定索引处的值。

IList.Insert(Int32, Object)

在所有情况下均引发 NotSupportedException

IList.IsFixedSize

获取一个值,该值指示此实例是否为固定大小。

IList.IsReadOnly

获取一个值,该值指示此实例是否为只读。

IList.Item[Int32]

获取或设置指定索引处的 Object

IList.Remove(Object)

在所有情况下均引发 NotSupportedException

IList.RemoveAt(Int32)

在所有情况下均引发 NotSupportedException

IList<T>.Insert(Int32, T)

在所有情况下均引发 NotSupportedException

IList<T>.Item[Int32]

获取或设置位于只读列表中指定索引处的元素。

IList<T>.RemoveAt(Int32)

在所有情况下均引发 NotSupportedException

IReadOnlyCollection<T>.Count

获取集合中的项数。

IReadOnlyList<T>.Item[Int32]

获取指定索引处的元素。

IStructuralComparable.CompareTo(Object, IComparer)

确定当前集合元素在排序顺序中的位置是位于另一个元素之前、之后还是与其位置相同。

IStructuralEquatable.Equals(Object, IEqualityComparer)

确定此数组在结构上是否等于指定的数组。

IStructuralEquatable.GetHashCode(IEqualityComparer)

返回当前实例的哈希代码。

扩展方法

ToFrozenDictionary<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)

FrozenDictionary<TKey,TValue>根据指定的键选择器函数从 IEnumerable<T> 创建 。

ToFrozenDictionary<TSource,TKey,TElement>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, IEqualityComparer<TKey>)

根据指定的键选择器和元素选择器函数,从 IEnumerable<T> 创建一个 FrozenDictionary<TKey,TValue>

ToFrozenSet<T>(IEnumerable<T>, IEqualityComparer<T>)

FrozenSet<T>使用指定的值创建 。

AsReadOnly<T>(IList<T>)

返回指定列表的只读 ReadOnlyCollection<T> 包装器。

BinarySearch<T>(ImmutableArray<T>, T)

使用默认比较器在已排序的数组中搜索指定的元素,如果已找到,则返回该元素的从零开始的索引。

BinarySearch<T>(ImmutableArray<T>, T, IComparer<T>)

在已排序的不可变数组中搜索指定的元素,如果已找到,则返回该元素的从零开始的索引。

BinarySearch<T>(ImmutableArray<T>, Int32, Int32, T)

在已排序的不可变数组中搜索指定的元素,如果已找到,则返回该元素的从零开始的索引。

BinarySearch<T>(ImmutableArray<T>, Int32, Int32, T, IComparer<T>)

在已排序的不可变数组中搜索指定的元素,并返回该元素的从零开始的索引。

ToImmutableArray<TSource>(IEnumerable<TSource>)

从指定的集合创建一个不可变数组。

ToImmutableDictionary<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>)

通过向源键应用转换函数,从现有元素集合构造一个不可变字典。

ToImmutableDictionary<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)

基于对序列进行某种形式的转换来构造一个不可变字典。

ToImmutableDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>)

枚举并转换序列,然后生成其内容的不可变字典。

ToImmutableDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>, IEqualityComparer<TKey>)

枚举并转换序列,然后使用指定的键比较器生成其内容的不可变字典。

ToImmutableDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>, IEqualityComparer<TKey>, IEqualityComparer<TValue>)

枚举并转换序列,然后使用指定的键和值比较器生成其内容的不可变字典。

ToImmutableHashSet<TSource>(IEnumerable<TSource>)

枚举序列,并生成其内容的不可变哈希集。

ToImmutableHashSet<TSource>(IEnumerable<TSource>, IEqualityComparer<TSource>)

枚举序列,生成其内容的不可变哈希集,并为集类型使用指定的相等性比较器。

IndexOf<T>(IImmutableList<T>, T)

搜索指定的对象,并返回列表中第一个匹配项的从零开始的索引。

IndexOf<T>(IImmutableList<T>, T, IEqualityComparer<T>)

搜索指定的对象,并返回列表中第一个匹配项的从零开始的索引。

IndexOf<T>(IImmutableList<T>, T, Int32)

搜索指定对象并返回不可变列表中从指定索引到最后一个元素这部分元素中第一个匹配项的从零开始索引。

IndexOf<T>(IImmutableList<T>, T, Int32, Int32)

搜索指定对象并返回不可变列表中从指定索引到最后一个元素这部分元素中第一个匹配项的从零开始索引。

LastIndexOf<T>(IImmutableList<T>, T)

搜索指定的对象,并返回整个不可变列表中最后一个匹配项的从零开始的索引。

LastIndexOf<T>(IImmutableList<T>, T, IEqualityComparer<T>)

搜索指定的对象,并返回整个不可变列表中最后一个匹配项的从零开始的索引。

LastIndexOf<T>(IImmutableList<T>, T, Int32)

搜索指定对象并返回不可变列表中从第一个元素到指定索引这部分元素中最后一个匹配项的从零开始的索引。

LastIndexOf<T>(IImmutableList<T>, T, Int32, Int32)

搜索指定对象并返回不可变列表中从第一个元素到指定索引这部分元素中最后一个匹配项的从零开始的索引。

Remove<T>(IImmutableList<T>, T)

从此列表中移除指定的值。

RemoveRange<T>(IImmutableList<T>, IEnumerable<T>)

从此列表中移除指定的值。

Replace<T>(IImmutableList<T>, T, T)

将列表中第一个相等的元素替换为指定的元素。

ToImmutableList<TSource>(IEnumerable<TSource>)

枚举序列,并生成其内容的不可变列表。

ToImmutableSortedDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>)

枚举并转换序列,然后生成其内容的不可变排序字典。

ToImmutableSortedDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>, IComparer<TKey>)

枚举并转换序列,然后使用指定的键比较器生成其内容的不可变排序字典。

ToImmutableSortedDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>, IComparer<TKey>, IEqualityComparer<TValue>)

枚举并转换序列,然后使用指定的键和值比较器生成其内容的不可变排序字典。

ToImmutableSortedSet<TSource>(IEnumerable<TSource>)

枚举序列,并生成其内容的不可变排序集。

ToImmutableSortedSet<TSource>(IEnumerable<TSource>, IComparer<TSource>)

枚举序列,生成其内容的不可变排序集,并使用指定的比较器。

CopyToDataTable<T>(IEnumerable<T>)

在给定其泛型参数 TDataTable 的输入 DataRow 对象的情况下,返回包含 IEnumerable<T> 对象副本的 DataRow

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption)

在给定其泛型参数 TDataRow 的输入 DataTable 对象的情况下,将 IEnumerable<T> 对象复制到指定的 DataRow

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler)

在给定其泛型参数 TDataRow 的输入 DataTable 对象的情况下,将 IEnumerable<T> 对象复制到指定的 DataRow

Aggregate<TSource>(IEnumerable<TSource>, Func<TSource,TSource,TSource>)

对序列应用累加器函数。

Aggregate<TSource,TAccumulate>(IEnumerable<TSource>, TAccumulate, Func<TAccumulate,TSource,TAccumulate>)

对序列应用累加器函数。 将指定的种子值用作累加器初始值。

Aggregate<TSource,TAccumulate,TResult>(IEnumerable<TSource>, TAccumulate, Func<TAccumulate,TSource,TAccumulate>, Func<TAccumulate,TResult>)

对序列应用累加器函数。 将指定的种子值用作累加器的初始值,并使用指定的函数选择结果值。

AggregateBy<TSource,TKey,TAccumulate>(IEnumerable<TSource>, Func<TSource, TKey>, TAccumulate, Func<TAccumulate,TSource,TAccumulate>, IEqualityComparer<TKey>)

表示不可变的数组;这意味着,该数组在创建后不可更改。

NuGet package: System.Collections.Immutable关于不可变集合和安装方法

AggregateBy<TSource,TKey,TAccumulate>(IEnumerable<TSource>, Func<TSource, TKey>, Func<TKey,TAccumulate>, Func<TAccumulate,TSource,TAccumulate>, IEqualityComparer<TKey>)

表示不可变的数组;这意味着,该数组在创建后不可更改。

NuGet package: System.Collections.Immutable关于不可变集合和安装方法

All<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

确定序列中的所有元素是否都满足条件。

Any<TSource>(IEnumerable<TSource>)

确定序列是否包含任何元素。

Any<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

确定序列中是否存在任意一个元素满足条件。

Append<TSource>(IEnumerable<TSource>, TSource)

将一个值追加到序列末尾。

AsEnumerable<TSource>(IEnumerable<TSource>)

返回类型化为 IEnumerable<T> 的输入。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Decimal>)

计算 Decimal 值序列的平均值,这些值可通过对输入序列的每个元素调用转换函数获得。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Double>)

计算 Double 值序列的平均值,这些值可通过对输入序列的每个元素调用转换函数获得。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Int32>)

计算 Int32 值序列的平均值,这些值可通过对输入序列的每个元素调用转换函数获得。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Int64>)

计算 Int64 值序列的平均值,这些值可通过对输入序列的每个元素调用转换函数获得。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Decimal>>)

计算可以为 null 的 Decimal 值序列的平均值,这些值可通过对输入序列的每个元素调用转换函数获得。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Double>>)

计算可以为 null 的 Double 值序列的平均值,这些值可通过对输入序列的每个元素调用转换函数获得。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int32>>)

计算可以为 null 的 Int32 值序列的平均值,这些值可通过对输入序列的每个元素调用转换函数获得。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int64>>)

计算可以为 null 的 Int64 值序列的平均值,这些值可通过对输入序列的每个元素调用转换函数获得。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Single>>)

计算可以为 null 的 Single 值序列的平均值,这些值可通过对输入序列的每个元素调用转换函数获得。

Average<TSource>(IEnumerable<TSource>, Func<TSource,Single>)

计算 Single 值序列的平均值,这些值可通过对输入序列的每个元素调用转换函数获得。

Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。

Chunk<TSource>(IEnumerable<TSource>, Int32)

将序列的元素拆分为最多 size大小的区块。

Concat<TSource>(IEnumerable<TSource>, IEnumerable<TSource>)

连接两个序列。

Contains<TSource>(IEnumerable<TSource>, TSource)

通过使用默认的相等比较器确定序列是否包含指定的元素。

Contains<TSource>(IEnumerable<TSource>, TSource, IEqualityComparer<TSource>)

通过使用指定的 IEqualityComparer<T> 确定序列是否包含指定的元素。

Count<TSource>(IEnumerable<TSource>)

返回序列中的元素数量。

Count<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

返回表示在指定的序列中满足条件的元素数量的数字。

CountBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)

表示不可变的数组;这意味着,该数组在创建后不可更改。

NuGet package: System.Collections.Immutable关于不可变集合和安装方法

DefaultIfEmpty<TSource>(IEnumerable<TSource>)

返回指定序列中的元素;如果序列为空,则返回单一实例集合中的类型参数的默认值。

DefaultIfEmpty<TSource>(IEnumerable<TSource>, TSource)

返回指定序列中的元素;如果序列为空,则返回单一实例集合中的指定值。

Distinct<TSource>(IEnumerable<TSource>)

通过使用默认的相等比较器对值进行比较,返回序列中的非重复元素。

Distinct<TSource>(IEnumerable<TSource>, IEqualityComparer<TSource>)

通过使用指定的 IEqualityComparer<T> 对值进行比较,返回序列中的非重复元素。

DistinctBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>)

根据指定的键选择器函数从序列中返回不同的元素。

DistinctBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)

根据指定的键选择器函数返回序列中的不同元素,并使用指定的比较器比较键。

ElementAt<TSource>(IEnumerable<TSource>, Index)

返回序列中指定索引处的元素。

ElementAt<TSource>(IEnumerable<TSource>, Int32)

返回序列中指定索引处的元素。

ElementAtOrDefault<TSource>(IEnumerable<TSource>, Index)

返回序列中指定索引处的元素;如果索引超出范围,则返回默认值。

ElementAtOrDefault<TSource>(IEnumerable<TSource>, Int32)

返回序列中指定索引处的元素;如果索引超出范围,则返回默认值。

Except<TSource>(IEnumerable<TSource>, IEnumerable<TSource>)

通过使用默认的相等比较器对值进行比较,生成两个序列的差集。

Except<TSource>(IEnumerable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>)

通过使用指定的 IEqualityComparer<T> 对值进行比较,生成两个序列的差集。

ExceptBy<TSource,TKey>(IEnumerable<TSource>, IEnumerable<TKey>, Func<TSource,TKey>)

根据指定的键选择器函数生成两个序列的集差。

ExceptBy<TSource,TKey>(IEnumerable<TSource>, IEnumerable<TKey>, Func<TSource,TKey>, IEqualityComparer<TKey>)

根据指定的键选择器函数生成两个序列的集差。

First<TSource>(IEnumerable<TSource>)

返回序列中的第一个元素。

First<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

返回序列中满足指定条件的第一个元素。

FirstOrDefault<TSource>(IEnumerable<TSource>)

返回序列中的第一个元素;如果序列中不包含任何元素,则返回默认值。

FirstOrDefault<TSource>(IEnumerable<TSource>, TSource)

返回序列的第一个元素,如果序列不包含任何元素,则返回指定的默认值。

FirstOrDefault<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

返回序列中满足条件的第一个元素;如果未找到这样的元素,则返回默认值。

FirstOrDefault<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>, TSource)

返回序列中满足条件的第一个元素;如果未找到此类元素,则返回指定的默认值。

GroupBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>)

根据指定的键选择器函数对序列中的元素进行分组。

GroupBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)

根据指定的键选择器函数对序列中的元素进行分组,并使用指定的比较器对键进行比较。

GroupBy<TSource,TKey,TElement>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>)

根据指定的键选择器函数对序列中的元素进行分组,并且通过使用指定的函数对每个组中的元素进行投影。

GroupBy<TSource,TKey,TElement>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, IEqualityComparer<TKey>)

根据键选择器函数对序列中的元素进行分组。 通过使用比较器对键进行比较,并且通过使用指定的函数对每个组的元素进行投影。

GroupBy<TSource,TKey,TResult>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TKey,IEnumerable<TSource>,TResult>)

根据指定的键选择器函数对序列中的元素进行分组,并且从每个组及其键中创建结果值。

GroupBy<TSource,TKey,TResult>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TKey,IEnumerable<TSource>,TResult>, IEqualityComparer<TKey>)

根据指定的键选择器函数对序列中的元素进行分组,并且从每个组及其键中创建结果值。 通过使用指定的比较器对键进行比较。

GroupBy<TSource,TKey,TElement,TResult>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, Func<TKey,IEnumerable<TElement>,TResult>)

根据指定的键选择器函数对序列中的元素进行分组,并且从每个组及其键中创建结果值。 通过使用指定的函数对每个组的元素进行投影。

GroupBy<TSource,TKey,TElement,TResult>(IEnumerable<TSource>, Func<TSource, TKey>, Func<TSource,TElement>, Func<TKey,IEnumerable<TElement>, TResult>, IEqualityComparer<TKey>)

根据指定的键选择器函数对序列中的元素进行分组,并且从每个组及其键中创建结果值。 通过使用指定的比较器对键值进行比较,并且通过使用指定的函数对每个组的元素进行投影。

GroupJoin<TOuter,TInner,TKey,TResult>(IEnumerable<TOuter>, IEnumerable<TInner>, Func<TOuter,TKey>, Func<TInner,TKey>, Func<TOuter,IEnumerable<TInner>, TResult>)

基于键值等同性对两个序列的元素进行关联,并对结果进行分组。 使用默认的相等比较器对键进行比较。

GroupJoin<TOuter,TInner,TKey,TResult>(IEnumerable<TOuter>, IEnumerable<TInner>, Func<TOuter,TKey>, Func<TInner,TKey>, Func<TOuter,IEnumerable<TInner>, TResult>, IEqualityComparer<TKey>)

基于键值等同性对两个序列的元素进行关联,并对结果进行分组。 使用指定的 IEqualityComparer<T> 对键进行比较。

Index<TSource>(IEnumerable<TSource>)

表示不可变的数组;这意味着,该数组在创建后不可更改。

NuGet package: System.Collections.Immutable关于不可变集合和安装方法

Intersect<TSource>(IEnumerable<TSource>, IEnumerable<TSource>)

通过使用默认的相等比较器对值进行比较,生成两个序列的交集。

Intersect<TSource>(IEnumerable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>)

通过使用指定的 IEqualityComparer<T> 对值进行比较,生成两个序列的交集。

IntersectBy<TSource,TKey>(IEnumerable<TSource>, IEnumerable<TKey>, Func<TSource,TKey>)

根据指定的键选择器函数生成两个序列的集合交集。

IntersectBy<TSource,TKey>(IEnumerable<TSource>, IEnumerable<TKey>, Func<TSource,TKey>, IEqualityComparer<TKey>)

根据指定的键选择器函数生成两个序列的集合交集。

Join<TOuter,TInner,TKey,TResult>(IEnumerable<TOuter>, IEnumerable<TInner>, Func<TOuter,TKey>, Func<TInner,TKey>, Func<TOuter,TInner,TResult>)

基于匹配键对两个序列的元素进行关联。 使用默认的相等比较器对键进行比较。

Join<TOuter,TInner,TKey,TResult>(IEnumerable<TOuter>, IEnumerable<TInner>, Func<TOuter,TKey>, Func<TInner,TKey>, Func<TOuter,TInner,TResult>, IEqualityComparer<TKey>)

基于匹配键对两个序列的元素进行关联。 使用指定的 IEqualityComparer<T> 对键进行比较。

Last<TSource>(IEnumerable<TSource>)

返回序列的最后一个元素。

Last<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

返回序列中满足指定条件的最后一个元素。

LastOrDefault<TSource>(IEnumerable<TSource>)

返回序列中的最后一个元素;如果序列中不包含任何元素,则返回默认值。

LastOrDefault<TSource>(IEnumerable<TSource>, TSource)

返回序列的最后一个元素,如果序列不包含任何元素,则返回指定的默认值。

LastOrDefault<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

返回序列中满足条件的最后一个元素;如果未找到这样的元素,则返回默认值。

LastOrDefault<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>, TSource)

返回序列中满足条件的最后一个元素;如果未找到此类元素,则返回指定的默认值。

LongCount<TSource>(IEnumerable<TSource>)

返回表示序列中元素总数的 Int64

LongCount<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

返回表示序列中满足条件的元素的数量的 Int64

Max<TSource>(IEnumerable<TSource>)

返回泛型序列中的最大值。

Max<TSource>(IEnumerable<TSource>, IComparer<TSource>)

返回泛型序列中的最大值。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Decimal>)

对序列中的每个元素调用转换函数,并返回最大的 Decimal 值。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Double>)

对序列中的每个元素调用转换函数,并返回最大的 Double 值。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Int32>)

对序列中的每个元素调用转换函数,并返回最大的 Int32 值。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Int64>)

对序列中的每个元素调用转换函数,并返回最大的 Int64 值。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Decimal>>)

对序列中的每个元素调用转换函数,并返回可以为 null 的最大的 Decimal 值。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Double>>)

对序列中的每个元素调用转换函数,并返回可以为 null 的最大的 Double 值。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int32>>)

对序列中的每个元素调用转换函数,并返回可以为 null 的最大的 Int32 值。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int64>>)

对序列中的每个元素调用转换函数,并返回可以为 null 的最大的 Int64 值。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Single>>)

对序列中的每个元素调用转换函数,并返回可以为 null 的最大的 Single 值。

Max<TSource>(IEnumerable<TSource>, Func<TSource,Single>)

对序列中的每个元素调用转换函数,并返回最大的 Single 值。

Max<TSource,TResult>(IEnumerable<TSource>, Func<TSource,TResult>)

对序列中的每个元素调用转换函数,并返回最大结果值。

MaxBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>)

根据指定的键选择器函数返回泛型序列中的最大值。

MaxBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IComparer<TKey>)

根据指定的键选择器函数和键比较器返回泛型序列中的最大值。

Min<TSource>(IEnumerable<TSource>)

返回泛型序列中的最小值。

Min<TSource>(IEnumerable<TSource>, IComparer<TSource>)

返回泛型序列中的最小值。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Decimal>)

对序列中的每个元素调用转换函数,并返回最小的 Decimal 值。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Double>)

对序列中的每个元素调用转换函数,并返回最小的 Double 值。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>)

对序列中的每个元素调用转换函数,并返回最小的 Int32 值。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Int64>)

对序列中的每个元素调用转换函数,并返回最小的 Int64 值。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Decimal>>)

对序列中的每个元素调用转换函数,并返回可以为 null 的最小的 Decimal 值。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Double>>)

对序列中的每个元素调用转换函数,并返回可以为 null 的最小的 Double 值。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int32>>)

对序列中的每个元素调用转换函数,并返回可以为 null 的最小的 Int32 值。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int64>>)

对序列中的每个元素调用转换函数,并返回可以为 null 的最小的 Int64 值。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Single>>)

对序列中的每个元素调用转换函数,并返回可以为 null 的最小的 Single 值。

Min<TSource>(IEnumerable<TSource>, Func<TSource,Single>)

对序列中的每个元素调用转换函数,并返回最小的 Single 值。

Min<TSource,TResult>(IEnumerable<TSource>, Func<TSource,TResult>)

对序列中的每个元素调用转换函数,并返回最小结果值。

MinBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>)

根据指定的键选择器函数返回泛型序列中的最小值。

MinBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IComparer<TKey>)

根据指定的键选择器函数和键比较器返回泛型序列中的最小值。

OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。

Order<T>(IEnumerable<T>)

按升序对序列的元素进行排序。

Order<T>(IEnumerable<T>, IComparer<T>)

按升序对序列的元素进行排序。

OrderBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>)

根据键按升序对序列的元素进行排序。

OrderBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IComparer<TKey>)

使用指定的比较器按升序对序列的元素进行排序。

OrderByDescending<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>)

根据键按降序对序列的元素进行排序。

OrderByDescending<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IComparer<TKey>)

使用指定的比较器按降序对序列的元素排序。

OrderDescending<T>(IEnumerable<T>)

按降序对序列的元素排序。

OrderDescending<T>(IEnumerable<T>, IComparer<T>)

按降序对序列的元素排序。

Prepend<TSource>(IEnumerable<TSource>, TSource)

向序列的开头添加值。

Reverse<TSource>(IEnumerable<TSource>)

反转序列中元素的顺序。

Select<TSource,TResult>(IEnumerable<TSource>, Func<TSource,TResult>)

将序列中的每个元素投影到新表单。

Select<TSource,TResult>(IEnumerable<TSource>, Func<TSource,Int32,TResult>)

通过合并元素的索引,将序列的每个元素投影到新窗体中。

SelectMany<TSource,TResult>(IEnumerable<TSource>, Func<TSource,IEnumerable<TResult>>)

将序列的每个元素投影到 IEnumerable<T> 并将结果序列合并为一个序列。

SelectMany<TSource,TResult>(IEnumerable<TSource>, Func<TSource,Int32,IEnumerable<TResult>>)

将序列的每个元素投影到 IEnumerable<T> 并将结果序列合并为一个序列。 每个源元素的索引用于该元素的投影表。

SelectMany<TSource,TCollection,TResult>(IEnumerable<TSource>, Func<TSource,IEnumerable<TCollection>>, Func<TSource,TCollection,TResult>)

将序列的每个元素投影到 IEnumerable<T>,并将结果序列合并为一个序列,并对其中每个元素调用结果选择器函数。

SelectMany<TSource,TCollection,TResult>(IEnumerable<TSource>, Func<TSource,Int32,IEnumerable<TCollection>>, Func<TSource,TCollection,TResult>)

将序列的每个元素投影到 IEnumerable<T>,并将结果序列合并为一个序列,并对其中每个元素调用结果选择器函数。 每个源元素的索引用于该元素的中间投影表。

SequenceEqual<TSource>(IEnumerable<TSource>, IEnumerable<TSource>)

通过使用相应类型的默认相等比较器对序列的元素进行比较,以确定两个序列是否相等。

SequenceEqual<TSource>(IEnumerable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>)

通过使用指定的 IEqualityComparer<T> 来比较两个序列的元素,以确定这两个序列是否相等。

Single<TSource>(IEnumerable<TSource>)

返回序列的唯一元素;如果该序列并非恰好包含一个元素,则会引发异常。

Single<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

返回序列中满足指定条件的唯一元素;如果有多个这样的元素存在,则会引发异常。

SingleOrDefault<TSource>(IEnumerable<TSource>)

返回序列中的唯一元素;如果该序列为空,则返回默认值;如果该序列包含多个元素,此方法将引发异常。

SingleOrDefault<TSource>(IEnumerable<TSource>, TSource)

返回序列的唯一元素,如果序列为空,则返回指定的默认值;如果序列中有多个元素,此方法将引发异常。

SingleOrDefault<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

返回序列中满足指定条件的唯一元素;如果这类元素不存在,则返回默认值;如果有多个元素满足该条件,此方法将引发异常。

SingleOrDefault<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>, TSource)

返回序列中满足指定条件的唯一元素;如果没有此类元素,则返回指定的默认值;如果多个元素满足条件,此方法将引发异常。

Skip<TSource>(IEnumerable<TSource>, Int32)

跳过序列中指定数量的元素,然后返回剩余的元素。

SkipLast<TSource>(IEnumerable<TSource>, Int32)

返回一个新的可枚举集合,它包含 source 中的元素,但省略了源集合中的 count 个元素。

SkipWhile<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

如果指定的条件为 true,则跳过序列中的元素,然后返回剩余的元素。

SkipWhile<TSource>(IEnumerable<TSource>, Func<TSource,Int32,Boolean>)

如果指定的条件为 true,则跳过序列中的元素,然后返回剩余的元素。 将在谓词函数的逻辑中使用元素的索引。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Decimal>)

计算 Decimal 值序列的总和,这些值可通过对输入序列中的每个元素调用转换函数获得。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Double>)

计算 Double 值序列的总和,这些值可通过对输入序列中的每个元素调用转换函数获得。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Int32>)

计算 Int32 值序列的总和,这些值可通过对输入序列中的每个元素调用转换函数获得。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Int64>)

计算 Int64 值序列的总和,这些值可通过对输入序列中的每个元素调用转换函数获得。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Decimal>>)

计算可以为 null 的 Decimal 值序列的总和,这些值可通过对输入序列的每个元素调用转换函数获得。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Double>>)

计算可以为 null 的 Double 值序列的总和,这些值可通过对输入序列的每个元素调用转换函数获得。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int32>>)

计算可以为 null 的 Int32 值序列的总和,这些值可通过对输入序列的每个元素调用转换函数获得。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int64>>)

计算可以为 null 的 Int64 值序列的总和,这些值可通过对输入序列的每个元素调用转换函数获得。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Single>>)

计算可以为 null 的 Single 值序列的总和,这些值可通过对输入序列的每个元素调用转换函数获得。

Sum<TSource>(IEnumerable<TSource>, Func<TSource,Single>)

计算 Single 值序列的总和,这些值可通过对输入序列中的每个元素调用转换函数获得。

Take<TSource>(IEnumerable<TSource>, Int32)

从序列的开头返回指定数量的相邻元素。

Take<TSource>(IEnumerable<TSource>, Range)

从序列中返回指定范围的连续元素。

TakeLast<TSource>(IEnumerable<TSource>, Int32)

返回一个新的可枚举集合,它包含 count 中的最后 source 个元素。

TakeWhile<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

只要指定的条件为 true,就会返回序列的元素。

TakeWhile<TSource>(IEnumerable<TSource>, Func<TSource,Int32,Boolean>)

只要指定的条件为 true,就会返回序列的元素。 将在谓词函数的逻辑中使用元素的索引。

ToArray<TSource>(IEnumerable<TSource>)

IEnumerable<T> 中创建数组。

ToDictionary<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>)

根据指定的键选择器函数,从 IEnumerable<T> 创建一个 Dictionary<TKey,TValue>

ToDictionary<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)

根据指定的键选择器函数和键比较器,从 IEnumerable<T> 创建一个 Dictionary<TKey,TValue>

ToDictionary<TSource,TKey,TElement>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>)

根据指定的键选择器和元素选择器函数,从 IEnumerable<T> 创建一个 Dictionary<TKey,TValue>

ToDictionary<TSource,TKey,TElement>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, IEqualityComparer<TKey>)

根据指定的键选择器函数、比较器和元素选择器函数,从 IEnumerable<T> 创建一个 Dictionary<TKey,TValue>

ToHashSet<TSource>(IEnumerable<TSource>)

IEnumerable<T> 创建一个 HashSet<T>

ToHashSet<TSource>(IEnumerable<TSource>, IEqualityComparer<TSource>)

使用 comparer 通过 IEnumerable<T> 创建 HashSet<T>,以用于比较键。

ToList<TSource>(IEnumerable<TSource>)

IEnumerable<T> 创建一个 List<T>

ToLookup<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>)

根据指定的键选择器函数,从 IEnumerable<T> 创建一个 Lookup<TKey,TElement>

ToLookup<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)

根据指定的键选择器函数和键比较器,从 IEnumerable<T> 创建一个 Lookup<TKey,TElement>

ToLookup<TSource,TKey,TElement>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>)

根据指定的键选择器和元素选择器函数,从 IEnumerable<T> 创建一个 Lookup<TKey,TElement>

ToLookup<TSource,TKey,TElement>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, IEqualityComparer<TKey>)

根据指定的键选择器函数、比较器和元素选择器函数,从 IEnumerable<T> 创建一个 Lookup<TKey,TElement>

TryGetNonEnumeratedCount<TSource>(IEnumerable<TSource>, Int32)

尝试在不强制枚举的情况下确定序列中的元素数。

Union<TSource>(IEnumerable<TSource>, IEnumerable<TSource>)

通过使用默认的相等比较器,生成两个序列的并集。

Union<TSource>(IEnumerable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>)

通过使用指定的 IEqualityComparer<T> 生成两个序列的并集。

UnionBy<TSource,TKey>(IEnumerable<TSource>, IEnumerable<TSource>, Func<TSource,TKey>)

根据指定的键选择器函数生成两个序列的集联合。

UnionBy<TSource,TKey>(IEnumerable<TSource>, IEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)

根据指定的键选择器函数生成两个序列的集联合。

Where<TSource>(IEnumerable<TSource>, Func<TSource,Boolean>)

基于谓词筛选值序列。

Where<TSource>(IEnumerable<TSource>, Func<TSource,Int32,Boolean>)

基于谓词筛选值序列。 将在谓词函数的逻辑中使用每个元素的索引。

Zip<TFirst,TSecond>(IEnumerable<TFirst>, IEnumerable<TSecond>)

使用两个指定序列中的元素生成元组序列。

Zip<TFirst,TSecond,TThird>(IEnumerable<TFirst>, IEnumerable<TSecond>, IEnumerable<TThird>)

使用三个指定序列中的元素生成元组序列。

Zip<TFirst,TSecond,TResult>(IEnumerable<TFirst>, IEnumerable<TSecond>, Func<TFirst,TSecond,TResult>)

将指定函数应用于两个序列的对应元素,以生成结果序列。

Aggregate<T>(ImmutableArray<T>, Func<T,T,T>)

以累加方式向元素序列应用函数。

Aggregate<TAccumulate,T>(ImmutableArray<T>, TAccumulate, Func<TAccumulate,T,TAccumulate>)

以累加方式向元素序列应用函数。

Aggregate<TAccumulate,TResult,T>(ImmutableArray<T>, TAccumulate, Func<TAccumulate,T,TAccumulate>, Func<TAccumulate,TResult>)

以累加方式向元素序列应用函数。

All<T>(ImmutableArray<T>, Func<T,Boolean>)

获取一个值,该值指示此数组中的所有元素是否与给定的条件匹配。

Any<T>(ImmutableArray<T>)

获取一个值,该值指示数组是否包含任何元素。

Any<T>(ImmutableArray<T>, Func<T,Boolean>)

获取一个值,该值指示数组是否包含与指定条件匹配的任何元素。

ElementAt<T>(ImmutableArray<T>, Int32)

返回数组中指定索引处的元素。

ElementAtOrDefault<T>(ImmutableArray<T>, Int32)

返回序列中指定索引处的元素;如果索引超出范围,则返回默认值。

First<T>(ImmutableArray<T>)

返回数组中的第一个元素。

First<T>(ImmutableArray<T>, Func<T,Boolean>)

返回序列中满足指定条件的第一个元素。

FirstOrDefault<T>(ImmutableArray<T>)

返回序列中的第一个元素;如果序列中不包含任何元素,则返回默认值。

FirstOrDefault<T>(ImmutableArray<T>, Func<T,Boolean>)

返回序列中满足条件的第一个元素;如果未找到这样的元素,则返回默认值。

Last<T>(ImmutableArray<T>)

返回数组的最后一个元素。

Last<T>(ImmutableArray<T>, Func<T,Boolean>)

返回序列中满足指定条件的最后一个元素。

LastOrDefault<T>(ImmutableArray<T>)

返回序列中的最后一个元素;如果序列中不包含任何元素,则返回默认值。

LastOrDefault<T>(ImmutableArray<T>, Func<T,Boolean>)

返回序列中满足条件的最后一个元素;如果未找到这样的元素,则返回默认值。

Select<T,TResult>(ImmutableArray<T>, Func<T,TResult>)

将序列中的每个元素投影到新表单。

SelectMany<TSource,TCollection,TResult>(ImmutableArray<TSource>, Func<TSource,IEnumerable<TCollection>>, Func<TSource,TCollection,TResult>)

将序列的每个元素投影到 IEnumerable<T>,并将结果序列合并为一个序列,并对其中每个元素调用结果选择器函数。

SequenceEqual<TDerived,TBase>(ImmutableArray<TBase>, IEnumerable<TDerived>, IEqualityComparer<TBase>)

根据相等比较器确定两个序列是否相等。

SequenceEqual<TDerived,TBase>(ImmutableArray<TBase>, ImmutableArray<TDerived>, IEqualityComparer<TBase>)

根据相等比较器确定两个序列是否相等。

SequenceEqual<TDerived,TBase>(ImmutableArray<TBase>, ImmutableArray<TDerived>, Func<TBase,TBase,Boolean>)

根据相等比较器确定两个序列是否相等。

Single<T>(ImmutableArray<T>)

返回序列的唯一元素;如果该序列并非恰好包含一个元素,则会引发异常。

Single<T>(ImmutableArray<T>, Func<T,Boolean>)

返回序列中满足指定条件的唯一元素;如果有多个这样的元素存在,则会引发异常。

SingleOrDefault<T>(ImmutableArray<T>)

返回数组中的唯一元素;如果序列为空,则返回默认值;如果序列包含多个元素,此方法将引发异常。

SingleOrDefault<T>(ImmutableArray<T>, Func<T,Boolean>)

返回序列中满足指定条件的唯一元素;如果这类元素不存在,则返回默认值;如果有多个元素满足该条件,此方法将引发异常。

ToArray<T>(ImmutableArray<T>)

将此数组的内容复制到不可变数组。

ToDictionary<TKey,T>(ImmutableArray<T>, Func<T,TKey>)

基于此数组的内容创建字典。

ToDictionary<TKey,T>(ImmutableArray<T>, Func<T,TKey>, IEqualityComparer<TKey>)

基于此数组的内容创建字典。

ToDictionary<TKey,TElement,T>(ImmutableArray<T>, Func<T,TKey>, Func<T,TElement>)

基于此数组的内容创建字典。

ToDictionary<TKey,TElement,T>(ImmutableArray<T>, Func<T,TKey>, Func<T,TElement>, IEqualityComparer<TKey>)

基于此数组的内容创建字典。

Where<T>(ImmutableArray<T>, Func<T,Boolean>)

基于谓词筛选值序列。

AsParallel(IEnumerable)

启用查询的并行化。

AsParallel<TSource>(IEnumerable<TSource>)

启用查询的并行化。

AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryable

AsQueryable<TElement>(IEnumerable<TElement>)

将泛型 IEnumerable<T> 转换为泛型 IQueryable<T>

Ancestors<T>(IEnumerable<T>)

返回元素集合,其中包含源集合中每个节点的上级。

Ancestors<T>(IEnumerable<T>, XName)

返回经过筛选的元素集合,其中包含源集合中每个节点的上级。 集合中仅包括具有匹配 XName 的元素。

DescendantNodes<T>(IEnumerable<T>)

返回源集合中每个文档和元素的子代节点的集合。

Descendants<T>(IEnumerable<T>)

返回元素集合,其中包含源集合中每个元素和文档的子代元素。

Descendants<T>(IEnumerable<T>, XName)

返回经过筛选的元素集合,其中包含源集合中每个元素和文档的子代元素。 集合中仅包括具有匹配 XName 的元素。

Elements<T>(IEnumerable<T>)

返回源集合中每个元素和文档的子元素的集合。

Elements<T>(IEnumerable<T>, XName)

返回源集合中经过筛选的每个元素和文档的子元素集合。 集合中仅包括具有匹配 XName 的元素。

InDocumentOrder<T>(IEnumerable<T>)

返回节点集合(其中包含源集合中的所有节点),并按文档顺序排列。

Nodes<T>(IEnumerable<T>)

返回源集合中每个文档和元素的子节点集合。

Remove<T>(IEnumerable<T>)

将源集合中的每个节点从其父节点中移除。

适用于

线程安全性

此类型是线程安全的。