-5
\$\begingroup\$

here is my code

string[,] table = new string[104,6];
int xIndex = -1;
int yIndex = 0;
string newPrevious = "placeholder";

string[] strData = {"P  ","B  ","P  ","PB ","P  ",P  "};
string OriginalData ="";

IEnumerator Win_Log(){

     for(int i = 0; i < strData.Length; i++){
        OriginalData += strData[i];
        OriginalData += ",";
     }
     string[] newNewData = strData.Split(',');

     foreach(string newStrData in newNewData){

     if(table.GetLength(0) < xIndex){
     break;
      }
   }
}

what i am trying to achieve here is that i need to compare the 3rd column of the table and check if there's a value on the 2nd row of the third column so something like this

i have table [104,6] so what i need to compare is table[3,1] and table [3,2].

how can achieve that

\$\endgroup\$

2 Answers 2

0
\$\begingroup\$

There is somewhat a way of doing this dude.

int i = 0;
int j = 0;
string[,] strArr = new string[2, 3];

strArr[0, 0] = "First";
strArr[0, 1] = "Second";

strArr[1, 0] = "Third";
strArr[1, 1] = "Fourth";

for (i = 0; i <= strArr.GetUpperBound(0); i++)
{
    for (j = 0; j <= strArr.GetUpperBound(0); j++)
    {
                MessageBox.Show (strArr[i, j]);
    }
}
\$\endgroup\$
0
2
\$\begingroup\$

Quick Google search gleans the gleans this.

I know when I started programming it was sometimes tough to word a question correctly for Google to give you the answer you are looking, however, it appears you may not be taking that step first.

There are a number of ways to do this and that answer from SoF should give you enough direction to get what you require.

The basic "Introduction to Programming 101" solution is to do a nested loop:

for (int i = 0; i < UPPER; i++)
            {
                for (int j = 0; j < UPPER; j++)
                {
                    //compare arrayA[i] to arrayB[j];
                }
            }

LINQ is one way... this can be expensive in some cases:

hasDuplicates = a.Intersect(b).Any();
\$\endgroup\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .