Enumerable.TryGetNonEnumeratedCount<TSource> 方法

定義

嘗試判斷序列中的專案數目,而不強制列舉。

public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
 static bool TryGetNonEnumeratedCount(System::Collections::Generic::IEnumerable<TSource> ^ source, [Runtime::InteropServices::Out] int % count);
public static bool TryGetNonEnumeratedCount<TSource> (this System.Collections.Generic.IEnumerable<TSource> source, out int count);
static member TryGetNonEnumeratedCount : seq<'Source> * int -> bool
<Extension()>
Public Function TryGetNonEnumeratedCount(Of TSource) (source As IEnumerable(Of TSource), ByRef count As Integer) As Boolean

類型參數

TSource

source 項目的類型。

參數

source
IEnumerable<TSource>

包含要計算之項目的序列。

count
Int32

當這個方法傳回時,會包含 中的 source 專案數目,如果計數在未列舉的情況下無法判斷,則為 0。

傳回

Boolean

true 如果 的計數 source 可以在不列舉的情況下判斷,則為 ,否則為 false

備註

方法會執行一系列類型測試,識別可判斷其計數而不列舉的常見子類型。 ICollection<T>這包括 LINQ 實作中使用的 、 ICollection 和 內部類型。

方法通常是常數時間作業,但最終取決於基礎集合實作的複雜度特性。

適用於