private Square buttonSquare(Button button) { foreach (Square square in Squares.All) { if (button == this[square]) return square; } // semi-colon not needed throw new ApplicationException("invalid button " + button.ToString()); //System.Windows.Forms.MessageBox.Show(String.Format("invalid button {0}", button)); }