HashSet<T> HashSet<T> HashSet<T> HashSet<T> Class

定義

表示一組值。Represents a set of values.

generic <typename T>
public ref class HashSet : System::Collections::Generic::ICollection<T>, System::Collections::Generic::IEnumerable<T>, System::Collections::Generic::IReadOnlyCollection<T>, System::Collections::Generic::ISet<T>, System::Runtime::Serialization::IDeserializationCallback, System::Runtime::Serialization::ISerializable
[System.Serializable]
public class HashSet<T> : System.Collections.Generic.ICollection<T>, System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IReadOnlyCollection<T>, System.Collections.Generic.ISet<T>, System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.ISerializable
type HashSet<'T> = class
    interface ICollection<'T>
    interface ISerializable
    interface IDeserializationCallback
    interface ISet<'T>
    interface IReadOnlyCollection<'T>
    interface seq<'T>
    interface IEnumerable
Public Class HashSet(Of T)
Implements ICollection(Of T), IDeserializationCallback, IEnumerable(Of T), IReadOnlyCollection(Of T), ISerializable, ISet(Of T)

類型參數

T

雜湊集中項目的類型。The type of elements in the hash set.

繼承
HashSet<T>HashSet<T>HashSet<T>HashSet<T>
屬性
實作

範例

下列範例示範如何合併兩個不同的集合。The following example demonstrates how to merge two disparate sets. 此範例會建立兩個HashSet<T>物件,並將它們分別填入偶數和奇數數字。This example creates two HashSet<T> objects, and populates them with even and odd numbers, respectively. 第三個HashSet<T>集,其中包含偶數從建立物件。A third HashSet<T> object is created from the set that contains the even numbers. 此範例接著會呼叫UnionWith方法,將奇數的數字組新增至第三個的集合。The example then calls the UnionWith method, which adds the odd number set to the third set.

using System;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        HashSet<int> evenNumbers = new HashSet<int>();
        HashSet<int> oddNumbers = new HashSet<int>();

        for (int i = 0; i < 5; i++)
        {
            // Populate numbers with just even numbers.
            evenNumbers.Add(i * 2);

            // Populate oddNumbers with just odd numbers.
            oddNumbers.Add((i * 2) + 1);
        }

        Console.Write("evenNumbers contains {0} elements: ", evenNumbers.Count);
        DisplaySet(evenNumbers);

        Console.Write("oddNumbers contains {0} elements: ", oddNumbers.Count);
        DisplaySet(oddNumbers);

        // Create a new HashSet populated with even numbers.
        HashSet<int> numbers = new HashSet<int>(evenNumbers);
        Console.WriteLine("numbers UnionWith oddNumbers...");
        numbers.UnionWith(oddNumbers);

        Console.Write("numbers contains {0} elements: ", numbers.Count);
        DisplaySet(numbers);

    }

    private static void DisplaySet(HashSet<int> set)
    {
        Console.Write("{");
        foreach (int i in set)
        {
            Console.Write(" {0}", i);
        }
        Console.WriteLine(" }");
    }
}
/* This example produces output similar to the following:
 * evenNumbers contains 5 elements: { 0 2 4 6 8 }
 * oddNumbers contains 5 elements: { 1 3 5 7 9 }
 * numbers UnionWith oddNumbers...
 * numbers contains 10 elements: { 0 2 4 6 8 1 3 5 7 9 }
 */
Imports System
Imports System.Collections.Generic

Class Program

    Shared Sub Main()

        Dim evenNumbers As HashSet(Of Integer) = New HashSet(Of Integer)()
        Dim oddNumbers As HashSet(Of Integer) = New HashSet(Of Integer)()

        For i As Integer = 0 To 4

            ' Populate evenNumbers with only even numbers.
            evenNumbers.Add(i * 2)

            ' Populate oddNumbers with only odd numbers.
            oddNumbers.Add((i * 2) + 1)
        Next i

        Console.Write("evenNumbers contains {0} elements: ", evenNumbers.Count)
        DisplaySet(evenNumbers)

        Console.Write("oddNumbers contains {0} elements: ", oddNumbers.Count)
        DisplaySet(oddNumbers)

        ' Create a new HashSet populated with even numbers.
        Dim numbers As HashSet(Of Integer) = New HashSet(Of Integer)(evenNumbers)
        Console.WriteLine("numbers UnionWith oddNumbers...")
        numbers.UnionWith(oddNumbers)

        Console.Write("numbers contains {0} elements: ", numbers.Count)
        DisplaySet(numbers)
    End Sub


    Private Shared Sub DisplaySet(ByVal coll As HashSet(Of Integer))
        Console.Write("{")
        For Each i As Integer In coll
            Console.Write(" {0}", i)
        Next i
        Console.WriteLine(" }")
    End Sub

End Class
' This example produces output similar to the following:
' evenNumbers contains 5 elements: { 0 2 4 6 8 }
' oddNumbers contains 5 elements: { 1 3 5 7 9 }
' numbers UnionWith oddNumbers...
' numbers contains 10 elements: { 0 2 4 6 8 1 3 5 7 9 }

備註

HashSet<T>類別提供高效能設定作業。The HashSet<T> class provides high-performance set operations. 一組為集合,其中包含任何重複的項目,且其項目位於不依特定順序。A set is a collection that contains no duplicate elements, and whose elements are in no particular order.

注意

HashSet<T> 會實作IReadOnlyCollection<T>開頭的介面.NET Framework 4.6.NET Framework 4.6; 在舊版的.NET Framework 中,HashSet<T>類別未實作此介面。HashSet<T> implements the IReadOnlyCollection<T> interface starting with the .NET Framework 4.6.NET Framework 4.6; in previous versions of the .NET Framework, the HashSet<T> class did not implement this interface.

容量HashSet<T>物件會是物件可包含的項目數。The capacity of a HashSet<T> object is the number of elements that the object can hold. AHashSet<T>物件的容量,會自動增加的項目加入至物件。A HashSet<T> object's capacity automatically increases as elements are added to the object.

HashSet<T>類別的數學設定模型為基礎,並提供高效能設定作業類似於存取的索引鍵Dictionary<TKey,TValue>Hashtable集合。The HashSet<T> class is based on the model of mathematical sets and provides high-performance set operations similar to accessing the keys of the Dictionary<TKey,TValue> or Hashtable collections. 簡單地說,HashSet<T>類別可以視為Dictionary<TKey,TValue>不含值的集合。In simple terms, the HashSet<T> class can be thought of as a Dictionary<TKey,TValue> collection without values.

AHashSet<T>集合沒有排序,而且不能包含重複的項目。A HashSet<T> collection is not sorted and cannot contain duplicate elements. 如果您的應用程式的效能比更重要順序或項目重複資料刪除,請考慮使用List<T>類別搭配Sort方法。If order or element duplication is more important than performance for your application, consider using the List<T> class together with the Sort method.

HashSet<T> 提供許多數學設定作業,例如組加法 (聯集),並設定減法。HashSet<T> provides many mathematical set operations, such as set addition (unions) and set subtraction. 下表列出提供HashSet<T>作業和其數學的對等項目。The following table lists the provided HashSet<T> operations and their mathematical equivalents.

HashSet 作業HashSet operation 數學的對等項目Mathematical equivalent
UnionWith 等位或設成加法Union or set addition
IntersectWith 交集Intersection
ExceptWith 設定減法Set subtraction
SymmetricExceptWith 對稱差異Symmetric difference

除了列出的設定作業,HashSet<T>類別也會提供方法來判斷集合是否相等,重疊的集合,以及一組是子集或另一個集合的超集。In addition to the listed set operations, the HashSet<T> class also provides methods for determining set equality, overlap of sets, and whether a set is a subset or superset of another set.

僅限.NET framework: 針對非常大型HashSet<T>物件,您可以藉由設定增加到 64 位元系統上的 2 億個元素的最大容量enabled屬性 <gcAllowVeryLargeObjects> 組態項目true中執行階段環境。.NET Framework only: For very large HashSet<T> objects, you can increase the maximum capacity to 2 billion elements on a 64-bit system by setting the enabled attribute of the <gcAllowVeryLargeObjects> configuration element to true in the run-time environment.

開頭.NET Framework 4.NET Framework 4,則HashSet<T>類別會實作ISet<T>介面。Starting with the .NET Framework 4.NET Framework 4, the HashSet<T> class implements the ISet<T> interface.

HashSet 和 LINQ 設定作業HashSet and LINQ Set Operations

LINQ 提供的存取權DistinctUnionIntersectExcept設定會實作任何資料來源上的作業IEnumerableIQueryable介面。LINQ provides access to the Distinct, Union, Intersect and Except set operations on any data source that implements the IEnumerable or IQueryable interfaces. HashSet<T> 提供較大且更穩固的集合,設定作業。HashSet<T> provides a larger and more robust collection of set operations. 例如,HashSet<T>提供的比較,例如IsSubsetOfIsSupersetOfFor example, HashSet<T> provides comparisons such as IsSubsetOf and IsSupersetOf.

LINQ 的主要差異設定作業並HashSet<T>作業時,LINQ 設定作業一律會傳回新IEnumerable<T>集合,而HashSet<T>相等的方法會修改目前的集合。The primary difference between LINQ set operations and HashSet<T> operations is that LINQ set operations always return a new IEnumerable<T> collection, whereas the HashSet<T> equivalent methods modify the current collection.

一般而言,如果您必須建立新的集合,或您的應用程式需要存取只提供的設定作業,使用 LINQ 設定作業上任何IEnumerable<T>集合或陣列即可。Typically, if you must create a new set or if your application needs access only to the provided set operations, using LINQ set operations on any IEnumerable<T> collection or array will be sufficient. 不過,如果您的應用程式需要額外設定作業的存取權或它不是理想或需要建立新的集合,使用HashSet<T>類別。However, if your application requires access to additional set operations, or if it is not desirable or necessary to create a new collection, use the HashSet<T> class.

下表顯示HashSet<T>作業和其對等的 LINQ 設定作業。The following table shows the HashSet<T> operations and their equivalent LINQ set operations.

HashSet 作業HashSet operation LINQ 對等項目LINQ equivalent
UnionWith Union
IntersectWith Intersect
ExceptWith Except
未提供。Not provided. Distinct
SymmetricExceptWith 未提供。Not provided.
Overlaps 未提供。Not provided.
IsSubsetOf 未提供。Not provided.
IsProperSubsetOf 未提供。Not provided.
IsSupersetOf 未提供。Not provided.
IsProperSupersetOf 未提供。Not provided.
SetEquals 未提供。Not provided.

建構函式

HashSet<T>() HashSet<T>() HashSet<T>() HashSet<T>()

初始化 HashSet<T> 類別的新執行個體,這個執行個體是空白的,並使用集合類型的預設相等比較子。Initializes a new instance of the HashSet<T> class that is empty and uses the default equality comparer for the set type.

HashSet<T>(IEnumerable<T>) HashSet<T>(IEnumerable<T>) HashSet<T>(IEnumerable<T>) HashSet<T>(IEnumerable<T>)

初始化 HashSet<T> 類別的新執行個體,這個執行個體會使用集合型別的預設相等比較子、包含從指定之集合複製的項目,並且具有足以容納所複製項目數的容量。Initializes a new instance of the HashSet<T> class that uses the default equality comparer for the set type, contains elements copied from the specified collection, and has sufficient capacity to accommodate the number of elements copied.

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

初始化 HashSet<T> 類別的新執行個體,這個執行個體會使用集合型別的指定相等比較子、包含從指定集合複製的項目,並且具有足以容納所複製項目數的容量。Initializes a new instance of the HashSet<T> class that uses the specified equality comparer for the set type, contains elements copied from the specified collection, and has sufficient capacity to accommodate the number of elements copied.

HashSet<T>(IEqualityComparer<T>) HashSet<T>(IEqualityComparer<T>) HashSet<T>(IEqualityComparer<T>) HashSet<T>(IEqualityComparer<T>)

初始化 HashSet<T> 類別的新執行個體,這個執行個體是空白的,並使用集合類型的指定相等比較子。Initializes a new instance of the HashSet<T> class that is empty and uses the specified equality comparer for the set type.

HashSet<T>(Int32) HashSet<T>(Int32) HashSet<T>(Int32) HashSet<T>(Int32)

HashSet<T> 類別的新執行個體初始化,該類別為空白,但為 capacity 項目保留了空間,並對集合類型使用預設相等比較子。Initializes a new instance of the HashSet<T> class that is empty, but has reserved space for capacity items and uses the default equality comparer for the set type.

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

HashSet<T> 類別的新執行個體初始化,該類別對集合類型使用指定的相等比較子,並擁有足夠容量容納 capacity 元素。Initializes a new instance of the HashSet<T> class that uses the specified equality comparer for the set type, and has sufficient capacity to accommodate capacity elements.

HashSet<T>(SerializationInfo, StreamingContext) HashSet<T>(SerializationInfo, StreamingContext) HashSet<T>(SerializationInfo, StreamingContext) HashSet<T>(SerializationInfo, StreamingContext)

使用序列化資料,初始化 HashSet<T> 類別的新執行個體。Initializes a new instance of the HashSet<T> class with serialized data.

屬性

Comparer Comparer Comparer Comparer

取得 IEqualityComparer<T> 物件,這個物件可用於判斷集合中的值是否相等。Gets the IEqualityComparer<T> object that is used to determine equality for the values in the set.

Count Count Count Count

取得集合中包含的項目數。Gets the number of elements that are contained in a set.

方法

Add(T) Add(T) Add(T) Add(T)

將指定的項目加入至集合。Adds the specified element to a set.

Clear() Clear() Clear() Clear()

將所有元素從 HashSet<T> 物件移除。Removes all elements from a HashSet<T> object.

Contains(T) Contains(T) Contains(T) Contains(T)

判斷 HashSet<T> 物件是否包含指定的項目。Determines whether a HashSet<T> object contains the specified element.

CopyTo(T[]) CopyTo(T[]) CopyTo(T[]) CopyTo(T[])

HashSet<T> 物件的項目複製到陣列。Copies the elements of a HashSet<T> object to an array.

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

從指定的陣列索引開始,將 HashSet<T> 物件的項目都複製到陣列中。Copies the elements of a HashSet<T> object to an array, starting at the specified array index.

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

從指定的陣列索引開始,將 HashSet<T> 物件的指定項目數複製到陣列中。Copies the specified number of elements of a HashSet<T> object to an array, starting at the specified array index.

CreateSetComparer() CreateSetComparer() CreateSetComparer() CreateSetComparer()

傳回 IEqualityComparer 物件,這個物件可用來進行 HashSet<T> 物件的相等測試。Returns an IEqualityComparer object that can be used for equality testing of a HashSet<T> object.

EnsureCapacity(Int32) EnsureCapacity(Int32) EnsureCapacity(Int32) EnsureCapacity(Int32)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
ExceptWith(IEnumerable<T>) ExceptWith(IEnumerable<T>) ExceptWith(IEnumerable<T>) ExceptWith(IEnumerable<T>)

從目前的 HashSet<T> 物件中,移除指定之集合內的所有項目。Removes all elements in the specified collection from the current HashSet<T> object.

GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

傳回會逐一查看 HashSet<T> 物件的列舉值。Returns an enumerator that iterates through a HashSet<T> object.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext)

實作 ISerializable 介面,並傳回序列化 HashSet<T> 物件所需的資料。Implements the ISerializable interface and returns the data needed to serialize a HashSet<T> object.

GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
IntersectWith(IEnumerable<T>) IntersectWith(IEnumerable<T>) IntersectWith(IEnumerable<T>) IntersectWith(IEnumerable<T>)

修改目前的 HashSet<T> 物件,以便僅包含該物件和指定之集合中同時出現的項目。Modifies the current HashSet<T> object to contain only elements that are present in that object and in the specified collection.

IsProperSubsetOf(IEnumerable<T>) IsProperSubsetOf(IEnumerable<T>) IsProperSubsetOf(IEnumerable<T>) IsProperSubsetOf(IEnumerable<T>)

判斷 HashSet<T> 物件是否為指定之集合的真子集。Determines whether a HashSet<T> object is a proper subset of the specified collection.

IsProperSupersetOf(IEnumerable<T>) IsProperSupersetOf(IEnumerable<T>) IsProperSupersetOf(IEnumerable<T>) IsProperSupersetOf(IEnumerable<T>)

判斷 HashSet<T> 物件是否為指定之集合的真超集。Determines whether a HashSet<T> object is a proper superset of the specified collection.

IsSubsetOf(IEnumerable<T>) IsSubsetOf(IEnumerable<T>) IsSubsetOf(IEnumerable<T>) IsSubsetOf(IEnumerable<T>)

判斷 HashSet<T> 物件是否為指定之集合的子集。Determines whether a HashSet<T> object is a subset of the specified collection.

IsSupersetOf(IEnumerable<T>) IsSupersetOf(IEnumerable<T>) IsSupersetOf(IEnumerable<T>) IsSupersetOf(IEnumerable<T>)

判斷 HashSet<T> 物件是否為指定之集合的超集。Determines whether a HashSet<T> object is a superset of the specified collection.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
OnDeserialization(Object) OnDeserialization(Object) OnDeserialization(Object) OnDeserialization(Object)

實作 ISerializable 介面,並於還原序列化完成時引發還原序列化事件。Implements the ISerializable interface and raises the deserialization event when the deserialization is complete.

Overlaps(IEnumerable<T>) Overlaps(IEnumerable<T>) Overlaps(IEnumerable<T>) Overlaps(IEnumerable<T>)

判斷目前的 HashSet<T> 物件與指定的集合是否共用通用的項目。Determines whether the current HashSet<T> object and a specified collection share common elements.

Remove(T) Remove(T) Remove(T) Remove(T)

HashSet<T> 物件移除指定的項目。Removes the specified element from a HashSet<T> object.

RemoveWhere(Predicate<T>) RemoveWhere(Predicate<T>) RemoveWhere(Predicate<T>) RemoveWhere(Predicate<T>)

HashSet<T> 集合中移除符合指定之述詞 (Predicate) 所定義條件的所有項目。Removes all elements that match the conditions defined by the specified predicate from a HashSet<T> collection.

SetEquals(IEnumerable<T>) SetEquals(IEnumerable<T>) SetEquals(IEnumerable<T>) SetEquals(IEnumerable<T>)

判斷 HashSet<T> 物件和指定的集合是否包含相同項目。Determines whether a HashSet<T> object and the specified collection contain the same elements.

SymmetricExceptWith(IEnumerable<T>) SymmetricExceptWith(IEnumerable<T>) SymmetricExceptWith(IEnumerable<T>) SymmetricExceptWith(IEnumerable<T>)

修改目前的 HashSet<T> 物件,以便僅包含該物件或指定之集合 (但非兩者) 中出現的項目。Modifies the current HashSet<T> object to contain only elements that are present either in that object or in the specified collection, but not both.

ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)
TrimExcess() TrimExcess() TrimExcess() TrimExcess()

HashSet<T> 物件的容量設定為所包含的項目實際數目,捨入為鄰近的實作特定值。Sets the capacity of a HashSet<T> object to the actual number of elements it contains, rounded up to a nearby, implementation-specific value.

TryGetValue(T, T) TryGetValue(T, T) TryGetValue(T, T) TryGetValue(T, T)

搜尋指定值的資料集,並傳回所找到的相等值 (如果有的話)。Searches the set for a given value and returns the equal value it finds, if any.

UnionWith(IEnumerable<T>) UnionWith(IEnumerable<T>) UnionWith(IEnumerable<T>) UnionWith(IEnumerable<T>)

修改目前的 HashSet<T> 物件,以包含該物件和 (或) 指定集合中出現的所有項目。Modifies the current HashSet<T> object to contain all elements that are present in itself, the specified collection, or both.

明確介面實作

ICollection<T>.Add(T) ICollection<T>.Add(T) ICollection<T>.Add(T) ICollection<T>.Add(T)

將項目加入至 ICollection<T> 物件。Adds an item to an ICollection<T> object.

ICollection<T>.IsReadOnly ICollection<T>.IsReadOnly ICollection<T>.IsReadOnly ICollection<T>.IsReadOnly

取得值,指出集合是否為唯讀。Gets a value indicating whether a collection is read-only.

IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator()

傳回逐一查看集合的列舉值。Returns an enumerator that iterates through a collection.

IEnumerable<T>.GetEnumerator() IEnumerable<T>.GetEnumerator() IEnumerable<T>.GetEnumerator() IEnumerable<T>.GetEnumerator()

傳回逐一查看集合的列舉值。Returns an enumerator that iterates through a collection.

Extension Methods

CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>)

傳回DataTable,其中包含副本DataRow物件,指定輸入IEnumerable<T>物件其中泛型參數TDataRowReturns a DataTable that contains copies of the DataRow objects, given an input IEnumerable<T> object where the generic parameter T is DataRow.

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

複本DataRow至指定的物件DataTable,根據輸入IEnumerable<T>物件其中泛型參數TDataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

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

複本DataRow至指定的物件DataTable,根據輸入IEnumerable<T>物件其中泛型參數TDataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

啟用查詢的平行化作業。Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

將轉換IEnumerableIQueryableConverts an IEnumerable to an IQueryable.

Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>)

傳回包含來源集合中每個節點祖系的項目集合。Returns a collection of elements that contains the ancestors of every node in the source collection.

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

傳回包含來源集合中每個節點祖系的已篩選項目集合。Returns a filtered collection of elements that contains the ancestors of every node in the source collection. 集合中只會包含具有相符之 XName 的項目。Only elements that have a matching XName are included in the collection.

DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>)

傳回來源集合中每個文件和項目之子代節點的集合。Returns a collection of the descendant nodes of every document and element in the source collection.

Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>)

傳回包含來源集合中每個項目和文件之子代項目的項目集合。Returns a collection of elements that contains the descendant elements of every element and document in the source collection.

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

傳回已篩選的項目集合,其中包含來源集合中每個項目和文件的子代項目。Returns a filtered collection of elements that contains the descendant elements of every element and document in the source collection. 集合中只會包含具有相符之 XName 的項目。Only elements that have a matching XName are included in the collection.

Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>)

傳回來源集合中每個項目和文件的子項目集合。Returns a collection of the child elements of every element and document in the source collection.

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

傳回來源集合中每個項目和文件的已篩選子項目集合。Returns a filtered collection of the child elements of every element and document in the source collection. 集合中只會包含具有相符之 XName 的項目。Only elements that have a matching XName are included in the collection.

InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>)

傳回包含來源集合中所有節點的節點集合,依據文件順序來排序。Returns a collection of nodes that contains all nodes in the source collection, sorted in document order.

Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>)

傳回來源集合中每個文件和項目的子節點集合。Returns a collection of the child nodes of every document and element in the source collection.

Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>)

在來源集合中,從每一個節點的父節點移除這些節點。Removes every node in the source collection from its parent node.

適用於

另請參閱