public void eaqual(Matrix b)                    //判断两个矩阵是否相等
        {
            if (this.value.GetLength(0) == b.value.GetLength(0) && this.value.GetLength(1) == b.value.GetLength(1))
            {
                for (int i = 0; i < this.value.GetLength(0); i++)
                    for (int j = 0; j < this.value.GetLength(1); j++)
                    {
                        if (b.value[i, j] == this.value[i, j])                            Console.WriteLine("这两个矩阵相等");                        else Console.WriteLine("这两个矩阵不相等");
                    }
            }

解决方案 »

  1.   

    改成bool的多好,不相等return false,相等的在最后return true
      

  2.   

    public void eaqual(Matrix b) //判断两个矩阵是否相等
      {
    bool isquals = true;
      if (this.value.GetLength(0) == b.value.GetLength(0) && this.value.GetLength(1) == b.value.GetLength(1))
      {
      for (int i = 0; i < this.value.GetLength(0); i++)
      for (int j = 0; j < this.value.GetLength(1); j++)
      {
      if (b.value[i, j] != this.value[i, j])  {
         isquals = false;break;
      }
      if(!isquals) break;
      }
      if(isquals) Console.WriteLine("这两个矩阵相等");
      else Console.WriteLine("这两个矩阵不相等");
      }