A better way to loop through lists
<p>So I have a couple of different lists that I'm trying to process and merge into 1 list.</p>

<p>Below is a snipet of code that I want to see if there was a better way of doing.
The reason why I'm asking is that some of these lists are rather large.  I want to see if there is a more efficient way of doing this.</p>

<p>As you can see I'm looping through a list, and the first thing I'm doing is to check to see if the CompanyId exists in the list.  If it does, then I find item in the list that I'm going to process.</p>

<p>pList is my processign list.  I'm adding the values from my different lists into this list.  </p>

<p><strong>I'm wondering if there is a "better way" of accomplishing the Exist and Find.</strong>  </p>

<pre><code>    boolean tstFind = false;
    foreach (parseAC item in pACList)
    {
        tstFind = pList.Exists(x =&gt; (x.CompanyId == item.key.ToString()));

        if (tstFind == true)
        {
            pItem = pList.Find(x =&gt; (x.CompanyId == item.key.ToString()));
            //Processing done here.  pItem gets updated here
            ...
         }
</code></pre>

<p>Just as a side note, I'm going to be researching a way to use joins to see if that is faster.  But I haven't gotten there yet.  The above code is my first cut at solving this issue and it appears to work.  However, since I have the time I want to see if there is a better way still.</p>

<p>Any input is greatly appreciated.</p>

<p>Time Findings:</p>

<ul>
<li><p>My current Find and Exists code takes about <strong>84 minutes</strong> to loop through the 5.5M items in the pACList.</p></li>
<li><p>Using pList.firstOrDefault(x=> x.CompanyId == item.key.ToString()); takes <strong>54 minutes</strong> to loop through 5.5M items in the pACList</p></li>
</ul>
