Note
This method is similar to the Enumerable.TryGetNonEnumeratedCount method in .NET 6 and above but can be used
in any targeted platform and considers also IReadOnlyCollectionT implementations.
public static bool TryGetCount<T>(
this IEnumerable<T> source,
out int count
)
<ExtensionAttribute>
Public Shared Function TryGetCount(Of T) (
source As IEnumerable(Of T),
<OutAttribute> ByRef count As Integer
) As Boolean
public:
[ExtensionAttribute]
generic<typename T>
static bool TryGetCount(
IEnumerable<T>^ source,
[OutAttribute] int% count
)
[<ExtensionAttribute>]
static member TryGetCount :
source : IEnumerable<'T> *
count : int byref -> bool
This method supports some public interfaces as well as some common LINQ iterators (on .NET Core/.NET platforms).