Mihaly Varga

Mihaly Varga

  • NA
  • 13
  • 8.3k

Checking Array Element by Element Picture

Jan 17 2013 9:59 AM
If you have already assigned a two-dimensional array with an image:

 private void PictureLoad()
        {
            int k = 0;
            for (int i = 0; i < pb.GetLength(0); i++)
            {
                for (int j = 0; j < pb.GetLength(1); j++)
                {
                    switch (Balls[k].EzColor)
                    {
                        case Color.RED:
                            pb[i, j].Image = Properties.Resources.red;
                            break;
                        case Color.BLUE:
                            pb[i, j].Image = Properties.Resources.blue;
                            break;
                        case Color.YELLOW:
                            pb[i, j].Image = Properties.Resources.yellow;
                            break;
                        case Color.GREEN:
                            pb[i, j].Image = Properties.Resources.green;
                            break;
                        case Color.PURPLE:
                            pb[i, j].Image = Properties.Resources.purple;
                            break;
                    }
                    k++;
                }
            }
        }


Later can you check  two elements in the array by the picture? So i have to check if the pk[0,1] and pb[0,2] have the same picture?

I tried this:


public bool Check()
         {

            if (pb[0, 0].Image == pb[0, 1].Image)
            {

                return true;
            }
            else return false;
        }




Its not working, if i have the same picture in the 0. and 1. place this code cant see that is the same picture.

Answers (1)