title: Iterate through Queue in c# while Dequeue for each iteration
body: <p>I am building a console card game in c#.</p>
  
  <p>I have one dealer and 4 players and I want the dealer to play with each player alone. So, I have put the players in a <code>Queue</code> so that they may be served in order.</p>
  
  <p>My problem is when iterating through all the players in the <code>Queue</code>. When I run my logic (seen below), the for loop will only execute 2 times because the <code>playerQueue</code> is <em>decreasing</em> while the <code>i</code> variable is increasing. </p>
  
  <p>Please help me find a way to rectify this. <br>
  I attempted a <code>While</code> loop, but it did not work because we manipulate <code>playerQueue.Count()</code>. </p>
  
  <pre><code>Queue&lt;Player&gt; playerQueue = new Queue&lt;Player&gt;();
  
  int number_of_players = 4;
  
  
  /// &lt;summary&gt;
  ///  Adds new player to Queue
  /// &lt;/summary&gt; 
  for (int i = 0; i &lt; number_of_players; i++)
  {
      Player player = new Player();
      playerQueue.Enqueue(player);
  }
  
  /// &lt;summary&gt;
  ///  Get the first player in the playerQueue
  /// &lt;/summary&gt;  
  
  // HERE IS THE PROBLEM
  for (int i = 0; i &lt; playerQueue.Count(); i++)
  { 
       System.Console.WriteLine(playerQueue.Count());
       System.Console.WriteLine(i);
  
       // Get the first player in the playerQueue 
       Player PlayerInGame = playerQueue.Dequeue();
  
      // Play the game with the current player in the queue
  }
  </code></pre>