Utils/Runtime/ArrayExtensions.cs

23 lines
511 B
C#

namespace Utils
{
public static class ArrayExtensions
{
public static T[] Append<T>(this T[] array, T item)
{
if (array == null)
{
return new T[] { item };
}
var result = new T[array.Length + 1];
for (var i = 0; i < array.Length; i++)
{
result[i] = array[i];
}
result[array.Length] = item;
return result;
}
}
}