Enumerable.TryGetNonEnumeratedCount<TSource> Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Attempts to determine the number of elements in a sequence without forcing an enumeration.
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
Type Parameters
- TSource
The type of the elements of source
.
Parameters
- source
- IEnumerable<TSource>
A sequence that contains elements to be counted.
- count
- Int32
When this method returns, contains the number of elements in source
, or 0 if the count couldn't be determined without enumeration.
Returns
true
if the count of source
can be determined without enumeration; otherwise, false
.
Remarks
The method performs a series of type tests, identifying common subtypes whose count can be determined without enumerating. This includes ICollection<T>, ICollection, and internal types used in the LINQ implementation.
The method is typically a constant-time operation, but ultimately this depends on the complexity characteristics of the underlying collection's implementation.
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기