Array - ClearAll

An Array extension method that clears the array.

Try it

public static void Main()
{
	int[] numbers = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };

    for (int i = 0; i < 9; i++)
    {
        Console.Write("{0} ", numbers[i]);
    }
    Console.WriteLine();
    Console.WriteLine();

    Console.WriteLine("After calling numbers.ClearAll()\n");
	// C# Extension Method: Array - ClearAll
    numbers.ClearAll();

    for (int i = 0; i < 9; i++)
    {
        Console.Write("{0} ", numbers[i]);
    }
}

View Source
using System;

public static partial class Extensions
{
    /// <summary>
    ///     An Array extension method that clears the array.
    /// </summary>
    /// <param name="this">The @this to act on.</param>
    public static void ClearAll(this Array @this)
    {
        Array.Clear(@this, 0, @this.Length);
    }
}