EnumerableExtensionsTryGetCountT(IEnumerableT, Int32) Method
Tries to get the number of elements in the source enumeration without enumerating it.
Namespace: KGySoft.CoreLibrariesAssembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.0.0
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
- source IEnumerableT
- The source to check.
- count Int32
- If this method returns , then this parameter contains the number of elements in the source enumeration. This parameter is passed uninitialized.
- T
- The type of the elements in the enumeration.
Boolean, if the number of elements could be determined without enumeration; otherwise,
.In Visual Basic and C#, you can call this method as an instance method on any object of type
IEnumerableT. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
This method supports some public interfaces as well as some common LINQ iterators (on .NET Core/.NET platforms).
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.