Full repo available at https://bitbucket.org/createdbyx/codefarts.utilities-extension-methods-only
/// <summary>
/// Removes a depth from the three dimensional sequence.
/// </summary>
/// <typeparam name="T">The type of the array.</typeparam>
/// <param name="array">The array whose values are to be removed.</param>
/// <param name="width">The width of the three dimensional sequence.</param>
/// <param name="height">The height of the three dimensional sequence.</param>
/// <param name="depth">The depth of to be removed from the three dimensional sequence.</param>
/// <returns>Returns the updated three dimensional sequence.</returns>
/// <exception cref="ArgumentOutOfRangeException">
/// width or height is less then 1. Or depth is less then 0 or greater then the depth of the three dimensional sequence.
/// </exception>
public static T[] Remove3DDepth<T>(this T[] array, int width, int height, int depth)
{
if (width < 1)
{
throw new ArgumentOutOfRangeException("width");
}
if (height < 1)
{
throw new ArgumentOutOfRangeException("height");
}
var length = width * height;
if (depth < 0 || depth > (array.Length / length))
{
throw new ArgumentOutOfRangeException("depth");
}
return array.RemoveRange(depth * length, length);
}