EnumerableExtensionsTryGetCountT(IEnumerableT, Int32) Method

Tries to get the number of elements in the source enumeration without enumerating it.


Namespace: KGySoft.CoreLibraries
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 7.1.0
public static bool TryGetCount<T>(
	this IEnumerable<T> source,
	out int count


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.

Type Parameters

The type of the elements in the enumeration.

Return Value

, if the number of elements could be determined without enumeration; otherwise, .

Usage Note

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).

See Also