<PackageReference Include="System.Drawing.Common" Version="9.0.8" />

CollectionExtensions

static class CollectionExtensions
using System.Runtime.CompilerServices; namespace System.Collections.Generic { internal static class CollectionExtensions { [NullableContext(1)] internal static List<T> CreateTrimmedList<[Nullable(2)] T>(this IReadOnlyList<T> readOnlyList, int count) { ArgumentOutOfRangeException.ThrowIfLessThan(((IReadOnlyCollection<T>)readOnlyList).Count, count, "count"); T[] array = readOnlyList as T[]; if (array != null) return new List<T>((IEnumerable<T>)new ArraySegment<T>(array, 0, count)); List<T> list = new List<T>((IEnumerable<T>)readOnlyList); list.RemoveRange(count, list.Count - count); return list; } } }