19 using System.Collections.Generic;
43 public static T[] Slice<T>(
this T[] array,
int start,
int length)
45 if (length <= 0 || length > array.Length - start)
47 throw new ArgumentOutOfRangeException(
50 "Length of sliced array must be between 1 and {0}.",
56 if (start < 0 || start > array.Length - 1)
58 throw new ArgumentOutOfRangeException(
61 "Start index of sliced array is {0}; array has {1} elements.",
67 T[] slice =
new T[length];
68 Array.Copy(array, start, slice, 0, length);
Extensions methods for arrays.