Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I merge all the cases into One?

private void makeMoleVisable(int mole, PictureBox MoleHill)
    {
        switch (mole)
        {
            case 1:
                if (p01.Image == pmiss.Image && MoleHill.Image == pHill.Image)
                {
                    molesmissed ++;
                }
                p01.Image = MoleHill.Image;
              break;
            case 2:
              if (p02.Image == pmiss.Image && MoleHill.Image == pHill.Image)
              {
                  molesmissed++;
              }
                p02.Image = MoleHill.Image;
                break;

** I have 36 of these case statements each one for another for a different picture box; how do I group them all into one case statement so my code can be more efficient**

like image 424
Alex Watson Avatar asked Jul 02 '12 20:07

Alex Watson


People also ask

How do you merge cases?

On the site map, select Service > Cases. Select at least two active case records that you want to merge, and then on the command bar, select Merge Cases. In the Merge Cases dialog box, from the list of cases, select the case the other cases will be merged into, and then select Merge.

Is it possible to merge cases in Salesforce?

You can merge cases from the Cases List View or from the Case Record Home. When you merge cases, you select one case to be the master. You can compare the field values, and select the values that you want to use in the master record. All related lists, feed items, and child records are added to the master.

How do I merge cases in netsuite?

Go to Lists > Support > Cases. Select a case you want to merge and click either View or Edit. On the case record, click Merge.


1 Answers

It looks like your case is used to select an image, then you always apply the same processing to the image.

How about storing the image in a List or Dictionary, use the mole value to retrieve the correct image, then process that image?

Something like

Dictionary<int, PictureBox> images;
var image = images[mole];
// do stuff to image

If the images are all numbered sequentially, a List is slightly more efficient. Remember that list indices are 0 based. If you number your images from 1 as seems to be the case from your switch statement (assumed in the following example), remember to adjust accordingly.

List<PictureBox> images;
int index = mole - 1; // Assumes mole starts with 1, so adjust to 0-based index
var image = images[index];
like image 84
Eric J. Avatar answered Sep 22 '22 11:09

Eric J.