1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
using System;
namespace Extensions
{
static class ArrayExtensions
{
public static void Split<T>(this T[] array, int index, out T[] first, out T[] second)
{
first = new T[index];
second = new T[array.Length - index];
Array.Copy(array, first, first.Length);
Array.Copy(array, index, second, 0, second.Length);
}
public static void Split<T>(this T[] array, out T[] first, out T[] second)
=> Split(array, array.Length / 2, out first, out second);
public static T[] Copy<T>(this T[] array)
{
T[] outArray = new T[array.Length];
Array.Copy(array, outArray, outArray.Length);
return outArray;
}
}
}
|