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
27
28
29
30
31
32
33
34
35
36
37
38
|
using System;
namespace Xamarin.Forms.Platform.iOS
{
internal static class ArrayExtensions
{
public static T[] Insert<T>(this T[] self, int index, T item)
{
var result = new T[self.Length + 1];
if (index > 0)
Array.Copy(self, result, index);
result[index] = item;
if (index < self.Length)
Array.Copy(self, index, result, index + 1, result.Length - index - 1);
return result;
}
public static T[] Remove<T>(this T[] self, T item)
{
return self.RemoveAt(self.IndexOf(item));
}
public static T[] RemoveAt<T>(this T[] self, int index)
{
var result = new T[self.Length - 1];
if (index > 0)
Array.Copy(self, result, index);
if (index < self.Length - 1)
Array.Copy(self, index + 1, result, index, self.Length - index - 1);
return result;
}
}
}
|