Table of Contents

Method AsCountable

Namespace
Gamelogic.Extensions.Algorithms
Assembly
Gamelogic.Extensions.dll

AsCountable<T>(IEnumerable<T>)

Converts the source to an IReadOnlyCollection<T>.

[Version(3, 0, 0)]
public static IReadOnlyCollection<T> AsCountable<T>(this IEnumerable<T> source)

Parameters

source IEnumerable<T>

The source to convert.

Returns

IReadOnlyCollection<T>

The source as an IReadOnlyCollection<T>.

Type Parameters

T

The type of elements in the source.

Remarks

Enumerate IEnumerable<T> using this to get a better solution for when you need only a count in addition to enumeration. If the source is already an IReadOnlyCollection<T>, it is casted, otherwise it is converted to an IReadOnlyCollection<T>. The resulting collection is enumerates multiple times, so if you want to avoid this e numerate the collecction to something else.