How to compare multidimensional arrays in C# ?

前端 未结 4 897
伪装坚强ぢ
伪装坚强ぢ 2020-12-30 23:47

How to compare multidimensional arrays? Just true/false.

double[,] data1 = new double[,] { { 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } };    
double[,] data2 = ne         


        
4条回答
  •  醉梦人生
    2020-12-31 00:15

    you can also try to solve it with 2 for-loops and comparing them with the counters.

    maybe something like this?

    for(int counter1 = 0; counter1 < data1.GetLength(0); counter1++)
    {
       for(int counter2 = 0; counter2 < data2.GetLength(1); counter2++)
       {
          if(data1[counter1, counter2] == data2[counter1, counter2])
          {
             bool isEqual = true;
          }    
       }
    }      
    

提交回复
热议问题