title: Tuple with For-Each loop
body: <p>I am not sure if I am doing something wrong here or if something is actually wrong.</p>
  
  <p>It might totally be an overlook which is why I sent it to community to take a look.</p>
  
  <p>I am creating a <code>List</code> of <code>Tuple&lt;T,Boolean&gt;</code> on client side and returning to WCF via REST JSON.
  I am getting the value perfectly fine at the server side. However, when I try to use them in a <code>for each</code> loop, the items show up as <code>NULL</code> and err out.</p>
  
  <p>Interestingly, I replaced the <code>for each</code> loop with Classic <code>for</code> loop and the code works perfectly file.</p>
  
  <p>Below is the code I am using. Also attaching is the image which contains details about my scenario I am putting here.</p>
  
  <pre><code>//This code fails
  foreach (Tuple&lt;Candidate, Boolean&gt; cand in candidateList) //candidateList has got items perfectly in it.
  {
    Candidate cd = cand.Item1; //cand comes out as NULL
      if (cd.IsShortlisted)
         InsertShortCandidates(jobPost.JobID.ToString(), cd.UserID, cd.MatchingScore.ToString());
      else
         RemoveShortCandidates(jobPost.JobID.ToString(), cd.UserID);
  }
  
  //This code runs perfectly fine
  for (Int32 idx = 0; idx &lt; candidateList.Count; idx++) // As expected candidateList has got items.
  {
      Tuple&lt;Candidate, Boolean&gt; cand = candidateList[idx]; // Here cand has got values good to be used further. 
      Candidate cd = cand.Item1;
      if (cd.IsShortlisted)
         InsertShortCandidates(jobPost.JobID.ToString(), cd.UserID, cd.MatchingScore.ToString());
      else
         RemoveShortCandidates(jobPost.JobID.ToString(), cd.UserID);
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/AQ0zx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AQ0zx.png" alt="Tuples with Foreach"></a></p>