Extensions.cs 487 B

12345678910111213141516171819
  1. namespace MinMaxAB;
  2. public static class Extensions
  3. {
  4. public static T ChooseRandom<T>(this T[] source) => source[Random.Shared.Next(0, source.Length)];
  5. public static T[,] Fill<T>(int cols, int rows, T value)
  6. {
  7. T[,] array = new T[cols, rows];
  8. for (int i = 0; i < array.GetLength(0); i++)
  9. {
  10. for (int j = 0; j < array.GetLength(1); j++)
  11. {
  12. array[i, j] = value;
  13. }
  14. }
  15. return array;
  16. }
  17. }