如何将一个Char数组的每个元素与此Char数组的所有元素进行比较?
我想从数组中选择一个元素并与该数组的每个元素进行比较。 我的数组是:Char [,] Chars = new char [81,4]; 例如
Chars[0,0] compare to Chars[1,0]
Chars[0,0] compare Chars[1,1]
Chars[0,0] compare Chars[1,2]
Chars[0,0] compare Chars[1,3]
.
.
..
Chars[0,1] compare Chars[1,0]
Chars[0,1] compare Chars[1,1]
Chars[0,1] compare Chars[1,2]
Chars[0,1] compare Chars[1,3]
。 。
答案 0 :(得分:1)
var lengthX = Chars.GetLength(0);
var lengthY = Chars.GetLength(1)
for (int x = 0; x < lengthX; x ++) {
for (int y = 0; y < lengthY; y ++) {
for (int i = 0; i < lengthX; i ++) {
for (int j = 0; j < lengthY; j ++) {
//Your code to compare Chars[x,y] to Chars[i,j]
}
}
}
}