Is there a more clever way of writing this piece of code? It does work but I thought there might be a better way of returning a matrix from multiplying the parameter by itself.
public static void Main(string[] args)
{
int[,] m1 = CreateMatrix(5);
}
static int[,] CreateMatrix(int rowscols)
{
int[,] result = new int[rowscols, rowscols];
int res = rowscols * rowscols;
int counter= 0;
for (int i = 0; i < rowscols; ++i)
{
for (int k = 0; k < rowscols; ++k)
{
result[i, k] = (res - counter);
counter += 1;
}
}
return result;
}