title: Method name expected- using lambda expressions wrong?
body: <p>I am implementing a <code>Contains(T item)</code> method in a custom collection.
  The following works(since it is basically a copy of Microsoft's implementation):</p>
  
  <pre><code>public class aCollection:IEnumerable&lt;T&gt;
  {
  T[] items;
  public int Count{ get; private set;}
  //...
  public bool Contains(T item)
  {
      EqualityComparer&lt;T&gt; defaultComparer = EqualityComparer&lt;T&gt;.Default;
      for (int i = 0; i &lt; Count; i++)
          if (defaultComparer.Equals(items[i], item))
              return true;
      return false;
  }
  }
  </code></pre>
  
  <p>However, while coming to this solution I have tried another way around it, yet I fails to understand the exact reason why the build fails with <code>Method name expected</code> error:</p>
  
  <pre><code>public class aCollection:IEnumerable&lt;T&gt;
  {
  T[] items;
  public int Count{ get; private set;}
  //...
  public bool Contains(T item)
  {
      for (int i = 0; i &lt; Count; i++)
          if ((x =&gt; x == item)(items[i]))    //Method name expected
              return true;
      return false;
  }
  }
  </code></pre>
  
  <p>What am I misunderstanding here in the usage of lambdas? Is it a case where I can't use them for some reason or maybe I just wrote the expression wrong?</p>
  
  <p>EDIT: What I expect the function to do is to check my collection to find out, if it contains the argument. The line in the for loop is supposed to compare the existing elements in the <code>T[] items</code> to the passed <code>T item</code> one by one, until a match is found and return <code>true</code>. Alternatively, if no match is found in the whole array, just return <code>false</code>.</p>
  
  <p>Thanks in advance,</p>
  
  <p>hlfrmn</p>