using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
static class ArrayExtensions {
public static void Fill<T>(this T[] xs, T val) {
for (int i = 0; i < xs.Length; i++) {
xs[i] = val;
}
}
public static void Fill<T>(this T[,] xs, T val) {
for (int i = 0; i < xs.GetLength(0); i++) {
for (int j = 0; j < xs.GetLength(1); j++) {
xs[i, j] = val;
}
}
}
}
class Program {
static void Display(int[] xs) {
Console.WriteLine("[{0}]", string.Join(",", xs));
}
static void Display(int[,] xs) {
var ls = new List<string>();
for (int i = 0; i < xs.GetLength(0); i++) {
var sb = new StringBuilder();
sb.Append('[');
for (int j = 0; j < xs.GetLength(1); j++) {
if (j > 0) sb.Append(',');
sb.Append(xs[i, j]);
}
sb.Append(']');
ls.Add(sb.ToString());
}
Console.WriteLine("[{0}]", string.Join(",", ls));
}
static void Main() {
int[] xs = new int[3];
Display(xs);
xs.Fill(10);
Display(xs);
int[,] ys = new int[2, 3];
Display(ys);
ys.Fill(5);
Display(ys);
}
}