mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-12 10:18:27 -04:00
Global usings and file scoped namespaces
This commit is contained in:
@@ -1,24 +1,21 @@
|
||||
using System;
|
||||
namespace NadekoBot.Extensions;
|
||||
|
||||
namespace NadekoBot.Extensions
|
||||
// made for customreactions because they almost never get added
|
||||
// and they get looped through constantly
|
||||
public static class ArrayExtensions
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
/// <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;
|
||||
}
|
||||
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