OptionExtensionsLinqGetNonEnumeratedCountT Method

Returns Some of the count of elements in the collection if the count is readily available without enumeration; None otherwise.
C#
var array = new int[3] { 0, 1, 2 };
Assert.Equal(Some(3), array.GetNonEnumeratedCount());

var odds = array.Where(num => num % 2 == 1);
Assert.Equal(None<int>(), odds.GetNonEnumeratedCount());

Definition

Namespace: Orx.Fun.Option
Assembly: Orx.Fun.Option (in Orx.Fun.Option.dll) Version: 1.2.1+ea79806fa5e0e04bfdaef2a1916930e75e2cde74
C#
public static Opt<int> GetNonEnumeratedCount<T>(
	this IEnumerable<T> collection
)

Parameters

collection  IEnumerableT
Collection to get non-enumerated count of.

Type Parameters

T
Element type.

Return Value

OptInt32

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

See Also