public static void Main()
int[,] first = new int[a1, a2];
qwer(first,ref a1,ref a2);
int[,] second = new int[b1, b2];
qwer(second,ref b1,ref b2);
double[,] abc = new double[a1, b2];
for (int i = 0; i <a1; i++)
for (int j = 0; j < b2; j++)
for (int k = 0; k < b1; k++)
abc[i, j] += (first[i, k] * second[k, j]);
Console.Write(abc[i, j]+"\t");
static void qwer(int[,] matrix,ref int m,ref int n)
Console.WriteLine("Please input the matrix's row");
m = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Please input the matrix's column");
n = Convert.ToInt32(Console.ReadLine());
for (int i = 0; i != matrix.GetLength(0); i++)
for (int j = 0; j != matrix.GetLength(1); j++)
Console.WriteLine("Please input the element of the matrix,where row=" + (i + 1) + " , " + "column=" + (j + 1));
matrix[i, j] = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("You have already finished defining the matrix... ");
Console.WriteLine("The matrix you input is: ");
for (int i = 0; i != matrix.GetLength(0); i++)
for (int j = 0; j != matrix.GetLength(1); j++)
Console.Write(matrix[i, j] + "\t");