title: Guess the number in C# with player chances
body: <p>I made a little game, but it's not work as I wanted to. 
  It is a Guess the number game. The player has 10 chances. But there is my problem. It's increase the value of playerChance until it's reach 10. What can I use instead of while? </p>
  
  <p>It's output is: </p>
  
  <pre><code>Guess the number game! Do you wanna play? y/n
  y
  The game started! What is your guess?
  78
  Your number was too high!
  Your number was too high!
  Your number was too high!
  Your number was too high!
  Your number was too high!
  Your number was too high!
  Your number was too high!
  Your number was too high!
  Your number was too high!
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>namespace GuessTheNumberGame_v1
  {
      class Program
      {
          static void Main(string[] args)
          {
              Console.WriteLine("Guess the number game! Do you wanna play? y/n");
              if (Console.ReadKey(true).KeyChar == 'y')
              {
                  Console.WriteLine("The game started! What is your guess?");
                  int playerGuess = Convert.ToInt32(Console.ReadLine());
  
                  Random r = new Random();
                  int compGuess = r.Next(1, 101);
  
                  int playerScore = 0;
                  int playerChance = 0;
  
                  bool play = true;
  
                  do
                  {
                      while (playerChance &lt; 10)
                      {
                          if (playerGuess &gt; compGuess)
                          {
                              ++playerChance;
                              Console.WriteLine("Your number was too high!");
                          }
                          else if (playerGuess &lt; compGuess)
                          {
                              Console.WriteLine("Your number was too small!");
                              ++playerChance;
                          }
                          else
                          {
                              ++playerScore;
                              Console.WriteLine("You win! \nYou have: " + playerScore + " points!");
                              playerChance = 0;
                          }
                      }
  
                      Console.WriteLine("Do you wanna play again? y/n");
                      if (Console.ReadKey(true).KeyChar == 'n')
                          play = false;
                  } while (play);     
              }
  
              else
              {
                  Console.ReadKey();
              }
          }
      }
  }
  </code></pre>