Search in an Array

  • Thread starter Thread starter Sorin Sandu
  • Start date Start date
Hi Sorin,

Depending on your array setup and if those two values are separate or on the same row:

int[,] n = new int[4, 5];
for (int i = 0; i <= n.GetUpperBound(0); i++)
{
for (int j = 0; j <= n.GetUpperBound(1); j++)
{
if (n[i, j] == MyInt)
DoSomething();
}
}

int[,] n = new int[5, 2];
for(int i = 0; i <= n.GetUpperBound(0); i++)
{
if(n[i,0] == MyFirstValue && n[i,1] == MySecondValue)
DoSomething();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top