Your extension method does not fill given array but return new enumerable.
var undefinedNumbers = new int[500];
var randomNumbers = undefinedNumbers.FillRandom(1, 100);
object.ReferenceEquals(undefinedNumbers, randomNumbers); // returns false
To fill given array change parameter type to
public static int[] FillRandom(this int[] array, int min, int max)
{
Random rndNum = new Random();
for(var i = 0; i < array.Length; i++)
{
array[i] = rndNum.Next(min, max);
}
}
Usage
int[] randomNumbers = new int[500].FillRandom(1, 100);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…