EnumerableExtensionsTryGetCountT(IEnumerableT, 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: 9.0.0-preview.1
C#
public static bool TryGetCount<T>(
	this IEnumerable<T> source,
	out int count
)

Parameters

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

T
The type of the elements in the enumeration.

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

Remarks

This method supports some public interfaces as well as some common LINQ iterators (on .NET Core/.NET platforms).

See Also