-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathArrayEx.cs
More file actions
25 lines (23 loc) · 794 Bytes
/
Copy pathArrayEx.cs
File metadata and controls
25 lines (23 loc) · 794 Bytes
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
using System;
namespace Inversion.Extensions {
/// <summary>
/// An extension class providing extensions for arrays.
/// </summary>
public static class ArrayEx {
/// <summary>
/// A simple extension that constructs a new array from one
/// provided by calling `.Clone()` on each element of the
/// provided array.
/// </summary>
/// <typeparam name="T">The type of the array elements.</typeparam>
/// <param name="self">The array to act upon.</param>
/// <returns>Provides a new array with elements cloned from the originating array.</returns>
public static T[] DeepClone<T>(this T[] self) where T : class, ICloneable {
T[] other = new T[self.Length];
for (int i = 0; i < self.Length; i++) {
other[i] = self[i].Clone() as T;
}
return other;
}
}
}