mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-12 10:18:27 -04:00
Restructured folders and project names, ci should be fixed
This commit is contained in:
24
src/NadekoBot/_Extensions/ArrayExtensions.cs
Normal file
24
src/NadekoBot/_Extensions/ArrayExtensions.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
|
||||
namespace NadekoBot.Extensions
|
||||
{
|
||||
// made for customreactions because they almost never get added
|
||||
// and they get looped through constantly
|
||||
public static class ArrayExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a new array from the old array + new element at the end
|
||||
/// </summary>
|
||||
/// <param name="input">Input array</param>
|
||||
/// <param name="added">Item to add to the end of the output array</param>
|
||||
/// <typeparam name="T">Type of the array</typeparam>
|
||||
/// <returns>A new array with the new element at the end</returns>
|
||||
public static T[] With<T>(this T[] input, T added)
|
||||
{
|
||||
var newCrs = new T[input.Length + 1];
|
||||
Array.Copy(input, 0, newCrs, 0, input.Length);
|
||||
newCrs[input.Length] = added;
|
||||
return newCrs;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user