DotNext by .NET Foundation and Contributors

<PackageReference Include="DotNext" Version="4.13.1" />

 Collection

public static class Collection
Provides utility methods to work with collections.
public static void AddAll<T>(this ICollection<T> collection, IEnumerable<T> items)

Adds multiple items into collection.

public static ReadOnlyCollectionView<TInput, TOutput> Convert<TInput, TOutput>(this IReadOnlyCollection<TInput> collection, Converter<TInput, TOutput> converter)

Returns lazily converted read-only collection.

public static Optional<T> PeekRandom<T>(this IReadOnlyCollection<T> collection, Random random)

Gets the random element from the collection.

public static T[] ToArray<T>(ICollection<T> collection)

Converts collection into single-dimensional array.

public static T[] ToArray<T>(IReadOnlyCollection<T> collection)

Converts read-only collection into single-dimensional array.