MatchCollection 类

定义

表示通过迭代方式将正则表达式模式应用于输入字符串找到的成功匹配集。 集合不可变(只读),没有公共构造函数。 Matches(String) 方法返回 MatchCollection 对象。

public ref class MatchCollection : System::Collections::ICollection
public ref class MatchCollection : System::Collections::Generic::ICollection<System::Text::RegularExpressions::Match ^>, System::Collections::Generic::IEnumerable<System::Text::RegularExpressions::Match ^>, System::Collections::Generic::IList<System::Text::RegularExpressions::Match ^>, System::Collections::Generic::IReadOnlyCollection<System::Text::RegularExpressions::Match ^>, System::Collections::Generic::IReadOnlyList<System::Text::RegularExpressions::Match ^>, System::Collections::IList
public class MatchCollection : System.Collections.ICollection
public class MatchCollection : System.Collections.Generic.ICollection<System.Text.RegularExpressions.Match>, System.Collections.Generic.IEnumerable<System.Text.RegularExpressions.Match>, System.Collections.Generic.IList<System.Text.RegularExpressions.Match>, System.Collections.Generic.IReadOnlyCollection<System.Text.RegularExpressions.Match>, System.Collections.Generic.IReadOnlyList<System.Text.RegularExpressions.Match>, System.Collections.IList
[System.Serializable]
public class MatchCollection : System.Collections.ICollection
type MatchCollection = class
    interface ICollection
    interface IEnumerable
type MatchCollection = class
    interface ICollection<Match>
    interface seq<Match>
    interface IEnumerable
    interface IList<Match>
    interface IReadOnlyCollection<Match>
    interface IReadOnlyList<Match>
    interface ICollection
    interface IList
type MatchCollection = class
    interface ICollection
    interface IEnumerable
    interface ICollection<Match>
    interface seq<Match>
    interface IList<Match>
    interface IReadOnlyCollection<Match>
    interface IReadOnlyList<Match>
    interface IList
[<System.Serializable>]
type MatchCollection = class
    interface ICollection
    interface IEnumerable
Public Class MatchCollection
Implements ICollection
Public Class MatchCollection
Implements ICollection(Of Match), IEnumerable(Of Match), IList, IList(Of Match), IReadOnlyCollection(Of Match), IReadOnlyList(Of Match)
继承
MatchCollection
属性
实现

示例

下面的示例演示了如何使用 MatchCollection 类来询问一组 Match 实例。

#using <System.dll>

using namespace System;
using namespace System::Text::RegularExpressions;
int main()
{
   // Define a regular expression for repeated words.
   Regex^ rx = gcnew Regex( "\\b(?<word>\\w+)\\s+(\\k<word>)\\b",static_cast<RegexOptions>(RegexOptions::Compiled | RegexOptions::IgnoreCase) );

   // Define a test string.        
   String^ text = "The the quick brown fox  fox jumps over the lazy dog dog.";

   // Find matches.
   MatchCollection^ matches = rx->Matches( text );

   // Report the number of matches found.
   Console::WriteLine( "{0} matches found.", matches->Count );

   // Report on each match.
   for each (Match^ match in matches)
   {
      String^ word = match->Groups["word"]->Value;
      int index = match->Index;
      Console::WriteLine("{0} repeated at position {1}", word, index);   
   }
}
using System;
using System.Text.RegularExpressions;

public class Test
{
    public static void Main ()
    {
        // Define a regular expression for repeated words.
        Regex rx = new Regex(@"\b(?<word>\w+)\s+(\k<word>)\b",
          RegexOptions.Compiled | RegexOptions.IgnoreCase);

        // Define a test string.
        string text = "The the quick brown fox  fox jumps over the lazy dog dog.";

        // Find matches.
        MatchCollection matches = rx.Matches(text);

        // Report the number of matches found.
        Console.WriteLine("{0} matches found in:\n   {1}",
                          matches.Count,
                          text);

        // Report on each match.
        foreach (Match match in matches)
        {
            GroupCollection groups = match.Groups;
            Console.WriteLine("'{0}' repeated at positions {1} and {2}",
                              groups["word"].Value,
                              groups[0].Index,
                              groups[1].Index);
        }
    }
}

// The example produces the following output to the console:
//       3 matches found in:
//          The the quick brown fox  fox jumps over the lazy dog dog.
//       'The' repeated at positions 0 and 4
//       'fox' repeated at positions 20 and 25
//       'dog' repeated at positions 49 and 53
Imports System.Text.RegularExpressions

Public Module Test

    Public Sub Main()
        ' Define a regular expression for repeated words.
        Dim rx As New Regex("\b(?<word>\w+)\s+(\k<word>)\b", _
               RegexOptions.Compiled Or RegexOptions.IgnoreCase)

        ' Define a test string.        
        Dim text As String = "The the quick brown fox  fox jumps over the lazy dog dog."
        
        ' Find matches.
        Dim matches As MatchCollection = rx.Matches(text)

        ' Report the number of matches found.
        Console.WriteLine("{0} matches found in:", matches.Count)
        Console.WriteLine("   {0}", text)

        ' Report on each match.
        For Each match As Match In matches
            Dim groups As GroupCollection = match.Groups
            Console.WriteLine("'{0}' repeated at positions {1} and {2}", _ 
                              groups.Item("word").Value, _
                              groups.Item(0).Index, _
                              groups.Item(1).Index)
        Next
    End Sub
End Module
' The example produces the following output to the console:
'       3 matches found in:
'          The the quick brown fox  fox jumps over the lazy dog dog.
'       'The' repeated at positions 0 and 4
'       'fox' repeated at positions 20 and 25
'       'dog' repeated at positions 49 and 53

注解

集合不可变(只读),没有公共构造函数。 Regex.Matches 方法返回 MatchCollection 对象。

集合包含零个或多个 System.Text.RegularExpressions.Match 对象。 如果匹配成功,则集合将填充输入字符串中找到的每个匹配项的一个 System.Text.RegularExpressions.Match 对象。 如果匹配失败,则集合不包含 System.Text.RegularExpressions.Match 对象,其 Count 属性等于零。

将正则表达式模式应用于特定输入字符串时,正则表达式引擎使用以下两种方法之一来生成 MatchCollection 对象:

  • 直接评估。

    一次填充 MatchCollection 对象,其中所有匹配项都是通过对 Regex.Matches 方法的特定调用生成的。 访问集合的 Count 属性时,将使用此方法。 它通常是填充集合的更昂贵的方法,并且需要更大的性能命中。

  • 延迟评估。

    MatchCollection 对象会根据需要按匹配填充。 它等效于正则表达式引擎重复调用 Regex.Match 方法,并将每个匹配项添加到集合中。 当集合通过其 GetEnumerator 方法进行访问,或使用 foreach 语句(以 C#)或 For Each...Next 语句(在 Visual Basic 中)进行访问时,将使用此方法。

若要循环访问集合的成员,应使用语言提供的集合迭代构造(如 C# 中的 foreach 和 Visual Basic 中的 For Each...Next),而不是检索由 GetEnumerator 方法返回的枚举器。

属性

Count

获取匹配项数。

IsReadOnly

获取一个值,该值指示集合是否为只读。

IsSynchronized

获取一个值,该值指示是否同步对集合的访问(线程安全)。

Item[Int32]

获取集合的单个成员。

SyncRoot

获取一个对象,该对象可用于同步对集合的访问。

方法

CopyTo(Array, Int32)

从给定索引处开始,将集合的所有元素复制到给定数组。

CopyTo(Match[], Int32)

从特定 Array 索引开始,将集合的元素复制到 Array

Equals(Object)

确定指定的对象是否等于当前对象。

(继承自 Object)
GetEnumerator()

提供循环访问集合的枚举器。

GetHashCode()

用作默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
ToString()

返回一个表示当前对象的字符串。

(继承自 Object)

显式接口实现

ICollection.CopyTo(Array, Int32)

将集合的所有元素复制到从指定索引处开始的指定数组。

ICollection.IsSynchronized

获取一个值,该值指示是否同步对集合的访问(线程安全)。

ICollection.SyncRoot

获取一个对象,该对象可用于同步对集合的访问。

ICollection<Match>.Add(Match)

调用此方法始终会引发 NotSupportedException

ICollection<Match>.Clear()

调用此方法始终会引发 NotSupportedException

ICollection<Match>.Contains(Match)

确定集合是否包含特定值。

ICollection<Match>.Remove(Match)

调用此方法始终会引发 NotSupportedException

IEnumerable<Match>.GetEnumerator()

返回循环访问集合的枚举器。

IList.Add(Object)

调用此方法始终会引发 NotSupportedException

IList.Clear()

从集合中删除所有项。

IList.Contains(Object)

确定集合是否包含特定值。

IList.IndexOf(Object)

确定集合中特定项的索引。

IList.Insert(Int32, Object)

调用此方法始终会引发 NotSupportedException

IList.IsFixedSize

获取一个值,该值指示集合是否具有固定大小。

IList.Item[Int32]

获取指定索引处的元素。

IList.Remove(Object)

调用此方法始终会引发 NotSupportedException

IList.RemoveAt(Int32)

调用此方法始终会引发 NotSupportedException

IList<Match>.IndexOf(Match)

确定集合中特定项的索引。

IList<Match>.Insert(Int32, Match)

调用此方法始终会引发 NotSupportedException

IList<Match>.Item[Int32]

获取指定索引处的元素。

IList<Match>.RemoveAt(Int32)

调用此方法始终会引发 NotSupportedException

扩展方法

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

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

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> 包装器。

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>)

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

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>)

返回一个包含 DataRow 对象副本的 DataTable,给定 IEnumerable<T> 对象的输入 IEnumerable<T> 对象,其中泛型参数 TDataRow

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

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

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

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

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>)

表示通过迭代方式将正则表达式模式应用于输入字符串找到的成功匹配集。 集合不可变(只读),没有公共构造函数。 Matches(String) 方法返回 MatchCollection 对象。

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

表示通过迭代方式将正则表达式模式应用于输入字符串找到的成功匹配集。 集合不可变(只读),没有公共构造函数。 Matches(String) 方法返回 MatchCollection 对象。

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>)

表示通过迭代方式将正则表达式模式应用于输入字符串找到的成功匹配集。 集合不可变(只读),没有公共构造函数。 Matches(String) 方法返回 MatchCollection 对象。

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>)

返回一个可枚举值,该枚举将元素的索引合并到元组中。

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)

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

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>)

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

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>)

从源集合的父节点中删除每个节点。

适用于