title: What is the fastest way to compare these two collections?
body: <p>I am noticing a huge performance issue with trying to get a list of keys in a ConcurrentDictionary value object that exist in an IEnumerable collection as follows:</p>
  <p>Customer object has:
  string CustomerNumber;
  string Location;</p>
  <pre><code>var CustomerDict = ConcurrentDictionary&lt;string, Customer&gt;();
  var customers = IEnumerable&lt;string&gt;();
  </code></pre>
  <p>I am trying to get a list of the keys in the dictionary where the <code>customers.CustomerNumber</code> is in the dictionary.   What I have is below the removeItems takes a very long time to return:</p>
  <pre><code>var removeItems = CustomerDict
      .Where(w =&gt; customers.Any(c =&gt; c == w.Value.CustomerNumber))
      .Select(s =&gt; s.Key)
      .ToList();
  
  foreach(var item in removeItems)
  {
     CustomerDict.TryRemove(item, out _);
  }
  </code></pre>
  <p>Any help would be much appreciated what best to do with this.</p>