public Matran Hieu2MT(Matran a, Matran b)
        {
            Matran c = new Matran(this.So_Hang, this.So_Cot);
            if (a.So_Hang == b.So_Hang && a.So_Cot == b.So_Cot)
            {
                for (int i = 0; i < this.So_Hang; i++)
                {
                    for (int j = 0; j < this.So_Cot; j++)

                        c.MT[i, j] = a.MT[i, j] - b.MT[i, j];

                }
            }
            else 
            { Console.WriteLine("\n\t Khong tru duoc !!!"); }
            return c;
        }
// Xuat Ma tran 
        //public void XuatMT() 
        //{ 
        //    Console.WriteLine("\t Ma tran: \n");
        //    for (int i = 1; i <= this.So_Hang; i++) 
        //    {
        //        for (int j = 1; j <= this.So_Cot; j++)
        //        {
        //            Console.Write("\t" + this.MT[i,j] +" "); 
        //        } 
        //        Console.WriteLine();
        //    }
        //}
case 4:
                        Console.WriteLine("\n\t Nhap ma tran thu 1: ");
                        M1.NhapMT();
                        Console.WriteLine("\n\t Nhap ma tran thu 2: ");
                        M2.NhapMT();
                        Console.WriteLine("\t Hieu hai ma tran la: ");
                        M3.Hieu2MT(M1, M2);
                        M3.XuatMT();
                        Console.ReadLine();
                        break;
  • I can minus 2 matrix. I dont understand reason why!!! I can print matrix M3. Can anyone help me? Thank you so much!

On line 4 you test if both matrices have equal rows and columns, before performing a minus operation. Seems correct to me. Line 37 is correct.
Line 38 calls a method, wich you placed in comments.
Line 22 reads for (int i = 1; i <= this.So_Hang; i++) should this not be for (int i = 0; i < this.So_Hang; i++)? Same for line 24.

this.So_Hang mean this.rows
this.So_Cot mean this.colum.
why this program can be run? T_T

Can you specify what exactly is happening? Error codes etc.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.