DotNext by Roman Sakno

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

 Collection

public static class Collection
Provides utility methods to work with collections.
using System; using System.Collections.Generic; namespace DotNext.Collections.Generic { public static class Collection { public static ReadOnlyCollectionView<T> AsReadOnlyView<T>(this ICollection<T> collection) { return new ReadOnlyCollectionView<T>(collection); } public static ReadOnlyCollectionView<I, O> Convert<I, O>(this IReadOnlyCollection<I> collection, Converter<I, O> converter) { return new ReadOnlyCollectionView<I, O>(collection, converter); } private static T[] ToArray<C, T>(C collection, int count) where C : class, IEnumerable<T> { T[] array = new T[count]; long num = 0; foreach (T item in (IEnumerable<T>)collection) { T[] array2 = array; long num2 = num; num = num2 + 1; array2[num2] = item; } return array; } public static T[] ToArray<T>(ICollection<T> collection) { return ToArray<ICollection<T>, T>(collection, collection.Count); } public static T[] ToArray<T>(IReadOnlyCollection<T> collection) { return ToArray<IReadOnlyCollection<T>, T>(collection, collection.Count); } public static void AddAll<T>(this ICollection<T> collection, IEnumerable<T> items) { items.ForEach(collection.Add); } } }