private static Square[] GetSquaresArray(int rank, byte b) { var squares = new List <Square>(); for (int i = 0; i < 8; ++i) { // 00010000 int bit = 1 << i; // 11101111 bit = ~bit; // if bit is set if ((b & bit) != b) { squares.Add(BitBoardHelper.GetSquare(rank, i)); } } return(squares.ToArray()); }