Note that there are some explanatory texts on larger screens.

plurals
  1. POIs there a more efficient way of coding than having these if statements?
    primarykey
    data
    text
    <p>For part of my code there is section which is the same if statement over and over again the only difference being one of the variables. Is there a better way of structuring my code?</p> <pre><code>if (buttonArray[m, j].BackColor == levelTwo &amp;&amp; buttonArray[m, a].BackColor == levelTwo &amp;&amp; buttonArray[i, j].BackColor == levelTwo) { buttonArray[i, j].BackColor = levelThree; buttonArray[m, j].BackColor = Color.Transparent; buttonArray[m, a].BackColor = Color.Transparent; } if (buttonArray[m, j].BackColor == levelThree &amp;&amp; buttonArray[m, a].BackColor == levelThree &amp;&amp; buttonArray[i, j].BackColor == levelThree) { buttonArray[i, j].BackColor = levelFour; buttonArray[m, j].BackColor = Color.Transparent; buttonArray[m, a].BackColor = Color.Transparent; } if (buttonArray[m, j].BackColor == levelFour &amp;&amp; buttonArray[m, a].BackColor == levelFour &amp;&amp; buttonArray[i, j].BackColor == levelFour) { buttonArray[i, j].BackColor = levelFive; buttonArray[m, j].BackColor = Color.Transparent; buttonArray[m, a].BackColor = Color.Transparent; } if (buttonArray[m, j].BackColor == levelFive &amp;&amp; buttonArray[m, a].BackColor == levelFive &amp;&amp; buttonArray[i, j].BackColor == levelFive) { buttonArray[i, j].BackColor = levelSix; buttonArray[m, j].BackColor = Color.Transparent; buttonArray[m, a].BackColor = Color.Transparent; } if (buttonArray[m, j].BackColor == levelSix &amp;&amp; buttonArray[m, a].BackColor == levelSix &amp;&amp; buttonArray[i, j].BackColor == levelSix) { buttonArray[i, j].BackColor = levelSeven; buttonArray[m, j].BackColor = Color.Transparent; buttonArray[m, a].BackColor = Color.Transparent; } if (buttonArray[m, j].BackColor == levelSeven &amp;&amp; buttonArray[m, a].BackColor == levelSeven &amp;&amp; buttonArray[i, j].BackColor == levelSeven) { buttonArray[i, j].BackColor = levelEight; buttonArray[m, j].BackColor = Color.Transparent; buttonArray[m, a].BackColor = Color.Transparent; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload