EnumerableExtensionsTryGetCount(IEnumerable, Int32) Method

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

Definition

Namespace: KGySoft.CoreLibraries
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 7.0.0
C#
public static bool TryGetCount(
	this IEnumerable source,
	out int count
)

Parameters

source  IEnumerable
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.

Return Value

Boolean
, 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 IEnumerable. 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).

See Also