title: Linq statement to select common elements between two collections
body: <p>I'm trying to implement a search function, and I want to select all elements that are common in variable <code>A</code> and <code>B</code> and remove the rest.</p>
  
  <p>My code looks like this:</p>
  
  <pre><code>A.ForEach(y =&gt;
  {
      temp = temp.Where(x =&gt; x.Id== y.Id);
  });
  </code></pre>
  
  <p>The problem is if <code>A</code> has some values that <code>temp</code> doesn't contain, I'll get an empty temp.</p>
  
  <p>I hope I'm clear enough, but just to make sure:
  If <code>A</code> contains 6, 10 and 
  <code>temp</code> contains 10, 7. I want to just have 10.</p>
  
  <p>What's correct join or any other Linq statement for this? I'm not able to use <code>intersect</code> since two variables are from different tables.</p>