这种方法发生了什么? [英] what is happening in this method?

查看:76
本文介绍了这种方法发生了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi hi

有这种方法,我无法得到它正在做的事情





< br $> b $ b

hi people
there is this method which i cannot get what it is doing




bool IsPass()
      {
          for (int i = 0; i < 7; i++)
          {
              for (int j = 0; j < 7; j++)
              {
                  if (GenerateArray.a[i, j] != Resource.arr1[i, j]) return false ;
              }
          }
          return true;
      }







与我混淆的主线是






the main line i'm confused with is

if (GenerateArray.a[i, j] != Resource.arr1[i, j]) return false ;
            }
        }
        return true;
    }







这里的generatearray和resouce是方法

i实际上无法理解[i,j]会做什么以及为什么返回false并返回true是写的

请帮助




here generatearray and resouce are method
i can't actually understand what [i,j] will do and why return false and return true are written
please help

推荐答案

它是两个多维数组中值的比较。

http://msdn.microsoft.com/en-us/library/2yd9wwz4.aspx [ ^ ]





It is a comparison of values in two multi-dimensional arrays.
http://msdn.microsoft.com/en-us/library/2yd9wwz4.aspx[^]


if (GenerateArray.a[i, j] != Resource.arr1[i, j]) 
  return false ;





因此,如果单元格中的值[i ,j] for matrix GenerateArray.a与Resource.arr1中的cell [i,j]不同,该方法返回false。



So if the value in cell [i, j] for matrix GenerateArray.a is different from cell [i,j] in Resource.arr1 the method returns false.


您最好阅读有关多维数组以及如何迭代多维数组的项目。

check

多维数组(C#编程指南) [ ^ ]

C#2D阵列 [ ^ ]



这里 GenerateArray.a Resource.arr1 是2D数组,你正在迭代这些项目并比较它们。

低于行比较两个数组中的相同项目。

You better read about Multidimensional arrays and how to iterate over items of Multidimensional arrays.
check
Multidimensional Arrays (C# Programming Guide)[^]
C# 2D Array[^]

here GenerateArray.a and Resource.arr1 are 2D arrays and you are iterating over the items and comparing them.
below line compare same item in both arrays.
GenerateArray.a[i, j] != Resource.arr1[i, j]



if以上条件不满意,那么你找到一个没有加工的项目并返回 false 并且存在方法。

如果所有项目都在加工,那么你的程序将会来到返回true行并存在返回值的方法为 true


您只是比较两个数组中的项目,如果一个数组中的所有项都匹配第二个数组中的所有项,则返回true,否则返回false。
You are simply comparing the items in the two arrays, if all items in one array matches to the all items in the second array, returns true, otherwise false.


这篇关于这种方法发生了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆