Try Get Non Enumerated Count<TSource>(IEnumerable<TSource>, Int32) Method
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
The type of the elements of
A sequence that contains elements to be counted.
When this method returns, contains the count of
source if successful, or zero if the method failed to determine the count.
true if the count of
source can be determined without enumeration; otherwise,
The method performs a series of type tests, identifying common subtypes whose count can be determined without enumerating; this includes ICollection<T>, ICollection as well as 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 implementation.