Dictionary foreach loop with multiple occurences
Don't write dead code - it rots like a corpse and makes it hard to maintain your code:


else if (counter &gt;= 27)
{
    //Do nothing
}



Just delete this.



You can use the ++ increment operator here:


counter = counter + 1;



Like this:

++counter;




There is a += operator you can use here:


counter = counter + 2;



Like this:

counter += 2;




There is a Math.Pow() method you can use:


temp2 = temp * temp;



Like this:

temp2 = Math.Pow(temp, 2);