title: C# Lambda Expression Speed
body: <p>I have not used many lambda expressions before and I ran into a case where I thought I could make slick use of one.  I have a custom list of ~19,000 records and I need to find out if a record exists or not in the list so instead of writing a bunch of loops or using linq to go through the list I decided to try this:</p>
  
  <pre><code>for (int i = MinX; i &lt;= MaxX; ++i)
  {
      tempY = MinY;
  
      while (tempY &lt;= MaxY)
      {
          bool exists = myList.Exists(item =&gt; item.XCoord == i &amp;&amp; item.YCoord == tempY);
  
          ++tempY;
      }
  }
  </code></pre>
  
  <p>Only problem is it take ~9 - 11 seconds to execute.  Am I doing something wrong is this just a case of where I shouldn't be using an expression like this? </p>
  
  <p>Thanks.</p>
  
  <p>EDIT: Sorry.  I should elaborate.  I am creating a list of records with the for and while loop and checking if that record exists in myList.  That is the only way I could think of going about it.  I will reevaluate it and see what I come with up. </p>