title: list contains an ID in linq
body: <p>I am trying to find a linq query so I can write it in an if statement.</p>
  
  <p>Pseudo code:</p>
  
  <p>IDList is a list of ints List&lt; int ></p>
  
  <pre><code>if (IDList.Contains (Object.Id)) Do something
  </code></pre>
  
  <p>but I can't seem to work out what need.</p>
  
  <p>In none-linq this works:</p>
  
  <pre><code>  foreach(int id in IDList )
       {
          if (id == Object.Id)
              break;
       }
  </code></pre>
  
  <p>but I want it as one line if possible.</p>
  
  <p>I first tried this:</p>
  
  <pre><code>IDList.Contains(Object.Id);
  </code></pre>
  
  <p>but this throws a compile error</p>
  
  <p>I'm wondering should it be one of these two?</p>
  
  <pre><code>  IDList.Any(id =&gt; id == Object.Id)
  </code></pre>
  
  <p>or </p>
  
  <pre><code>IDList.Exists(id =&gt; id == Object.Id);
  </code></pre>
  
  <p>I don't completely understand how the lambdas and things work or the difference between andy and exists so I'm not sure if I'm along the wrong line?</p>