Website may be up and down over next few months. I'm currently doing a complete overhaul of everything. Going back to simple individual .htm pages, new overall site theme, sanitizing and cleaning up html of all pages and blog posts, attempting to implement a new tooling and publishing system etc etc.

Full repo available at https://bitbucket.org/createdbyx/codefarts.utilities-extension-methods-only

/// <summary>
/// Inserts one array into another array at the specified index.
/// </summary>
/// <typeparam name="T">Specifies the generic type of the array.</typeparam>
/// <param name="array">The destination array.</param>
/// <param name="index">The index in the destination array where insertion takes place.</param>
/// <param name="sourceArray">The source array that will be inserted.</param>
/// <returns>Returns the resized and updated destination array.</returns>
/// <exception cref="ArgumentOutOfRangeException">
/// If 'index' is out of bounds of the destination array.
/// </exception>
public static T[] Insert<T>(this T[] array, int index, T[] sourceArray)
{
    if (array == null || sourceArray == null || sourceArray.Length == 0)
    {
        return array;
    }

    if (index < 0)
    {
        throw new ArgumentOutOfRangeException("index");
    }

    if (index > array.Length + 1)
    {
        throw new ArgumentOutOfRangeException("index");
    }

    Array.Resize(ref array, array.Length + sourceArray.Length);
    Array.Copy(array, index, array, index + sourceArray.Length, array.Length - sourceArray.Length - index);
    sourceArray.CopyTo(array, index);
    return array;
}

Add comment



biuquote
  • Comment
  • Preview
Loading






Created by: X

Just another personal website in this crazy online world

Name of author Dean Lunz (aka Created by: X)
Computer programming nerd, and tech geek.
About Me -- Resume