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>執行從開始.NET Framework 4.6.NET Framework 4.6HashSet<T>介面; 在舊版的 .NET Framework 中, 類別並未實作為此介面。 IReadOnlyCollection<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. HashSet<T>物件的容量會隨著元素加入至物件而自動增加。A HashSet<T> object's capacity automatically increases as elements are added to the object.

類別是以數學集的模型為基礎, 並提供高效能設定作業, 類似于存取Dictionary<TKey,TValue>Hashtable集合的索引鍵。 HashSet<T>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.

HashSet<T>集合未排序, 且不能包含重複的元素。A HashSet<T> collection is not sorted and cannot contain duplicate elements. 如果 order 或 element 重複比應用程式的效能更重要, 請考慮將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>提供許多數學設定作業, 例如 set 加法 (等位) 和設定減法。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 或 set 加法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>的物件, 您可以在執行時間環境中, 將<gcAllowVeryLargeObjects> configuration 專案的enabled屬性設為true , 以將64位系統上的最大容量增加到2000000000個元素。.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 ISet<T> , 類別會實作為介面。 HashSet<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 可讓您存取Distinct任何Union執行Intersect IEnumerableExcept 介面之資料來源上的、IQueryable和設定作業。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>會提供IsSubsetOfIsSupersetOf之類的比較。For example, HashSet<T> provides comparisons such as IsSubsetOf and IsSupersetOf.

Linq set 作業和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.

一般而言, 如果您必須建立新的集合, 或如果您的應用程式只需要存取所提供的集合作業, 則在任何IEnumerable<T>集合或陣列上使用 LINQ set 作業就已足夠。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 set 作業。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)

確保此雜湊集可以包含指定的元素數目,而不需要擴充。Ensures that this hash set can hold the specified number of elements without growing.

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.

擴充方法

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

根據輸入 DataTable 物件 (其中泛型參數 TDataRow) 傳回包含 IEnumerable<T> 物件複本的 DataRowReturns 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 物件 (其中泛型參數 TDataTable),將 IEnumerable<T> 物件複製到指定的 DataRowCopies 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 物件 (其中泛型參數 TDataTable),將 IEnumerable<T> 物件複製到指定的 DataRowCopies 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)

IEnumerable 轉換成 IQueryableConverts 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.

適用於

另請參閱