.NET Fiddle

CSharp · Console

/Program.cs

using System;

					
public class Program
{
	public static void Main()
	{
		int a1=0, a2=0;
           
            int[,] first = new int[a1, a2];

            qwer(first,ref a1,ref a2);

            
            int b1 = 0, b2 = 0;
            int[,] second = new int[b1, b2];

            qwer(second,ref b1,ref b2);



            

            if (b1==a2)
            {
                double[,] abc = new double[a1, b2];


                for (int i = 0; i <a1; i++)
                {
                    for (int j = 0; j < b2; j++)

                    {
                        abc[i, j] = 0;
                        for (int k = 0; k < b1; k++)
                        {
                            abc[i, j] += (first[i, k] * second[k, j]);
                        }
                        Console.Write(abc[i, j]+"\t");
                    }
                    Console.WriteLine();
                }
            }
           
        }
        static void qwer(int[,] matrix,ref int m,ref int n)
        {
           
            Console.WriteLine("Please input the matrix's row");
            m = Convert.ToInt32(Console.ReadLine()); // m為列數
            Console.WriteLine("Please input the matrix's column");
            n = Convert.ToInt32(Console.ReadLine()); // n為行數
             matrix = new int[m, n];
            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");
                }
                Console.WriteLine();
            }
           
        }
    }
        
	
;