How do I quicky fill an array with a specific value?
I am not aware of such a method. You could write one yourself, though:
public static void Init<T>(this T[] array, T value)
{
for(int i=0; i < array.Length; ++i)
{
array[i] = value;
}
}
You can call it like this:
int[] myArray = new int[5];
myArray.Init(-1);
The other way is:
int[] arr = Enumerable.Repeat(-1, 10).ToArray();
Console.WriteLine(string.Join(",",arr));