using System; class Matrix { private int rows; private int cols; private T[,] matrix; public Matrix() { rows = cols = 0; matrix = null; } public Matrix(int m, int n) { rows = m; cols = n; matrix = new T[m, n]; } public T this[int i, int j] { get { if (i < rows && j < cols) return matrix[i, j]; else throw new ArgumentOutOfRangeException(); } set { if (i < rows && j < cols) matrix[i, j] = value; else throw new ArgumentOutOfRangeException(); } } public double Rows { get { return rows; } } public double Cols { get { return cols; } } } public class Test { public static void Main() { Matrix myMatrix=new Matrix(3,2); myMatrix[0,0]=1.5; myMatrix[0,1]=16.0; myMatrix[1,0]=18.0; myMatrix[1,1]=3.6; myMatrix[2,0]=7.1; myMatrix[2,1]=2.9; for(int i=0; i<3; i++) { for(int j=0; j<2; j++) Console.Write(myMatrix[i,j] + "\t"); Console.WriteLine(); } } }