The fastest method I have found uses Array.Copy with the copy size doubling each time through the loop. The speed is basically the same whether you fill the array with a single value or an array of values.
In my test with 20,000,000 array items, this function is twice as fast as a for loop.
using System;
namespace Extensions
{
public static class ArrayExtensions
{
public static void Fill<T>(this T[] destinationArray, params T[] value)
{
if (destinationArray == null)
{
throw new ArgumentNullException("destinationArray");
}
if (value.Length >= destinationArray.Length)
{
throw new ArgumentException("Length of value array must be less than length of destination");
}
// set the initial array value
Array.Copy(value, destinationArray, value.Length);
int arrayToFillHalfLength = destinationArray.Length / 2;
int copyLength;
for(copyLength = value.Length; copyLength < arrayToFillHalfLength; copyLength <<= 1)
{
Array.Copy(destinationArray, 0, destinationArray, copyLength, copyLength);
}
Array.Copy(destinationArray, 0, destinationArray, copyLength, destinationArray.Length - copyLength);
}
}
}
I blogged about this at https://secureapplicationlifestyle.com/2011/11/initialize-array-to-value-in-c-very.html and https://secureapplicationlifestyle.com/2014/04/better-array-fill-function.html