【发布时间】:2017-03-24 13:25:02
【问题描述】:
好的,所以我有 2 个锯齿状数组,我想遍历它们并将每个数组与另一个锯齿状数组中的每个数组进行比较。 所以在这个例子中,我想在 access[1] == visual[0] 时返回 true。
但似乎我无法明确比较锯齿状数组中的数组。我怎样才能引用整个数组,而不仅仅是这些数组中的元素?
我的意思是如果我写access[0][0],我会得到"10"。但我不能写access[0] 得到"10","16"
string[][] access = new string[][] {
new string[] {"10","16"},
new string[] {"100","20"},
new string[] {"1010","2"},
new string[] {"1011","1"}
};
string[][] visual = new string[][] {
new string[] {"100","20"},
new string[] {"101","36"},
new string[] {"101","37"},
new string[] {"101","38"}
};
【问题讨论】:
-
您的问题存在于同一级别:您不能直接比较两个
string[]数组...您必须逐个元素地比较它们... -
而 但我不能写 access[0] 来获得 "10","16"... 以同样的方式,使用一维数组
string[] access = { "10, 16" },你不能写access来得到"10", "16"
标签: c# arrays compare comparison jagged-arrays