title: C# In() method? (like Sql)
body: <p>I'm having a hard time finding what, I think, should be a fairly simple method.</p>
  
  <p>I think we've all used this:</p>
  
  <pre><code>select someThing from someTable where someColumn in('item1', 'item2')
  </code></pre>
  
  <p>In C#, I've have to write stuff like this:</p>
  
  <pre><code>if (someEnum == someEnum.Enum1 || someEnum == someEnum.Enum2 || 
    someEnum == someEnum.Enum3)
  {
    this.DoSomething();
  }
  </code></pre>
  
  <p>This works, but it's just wordy.</p>
  
  <p>Out of frustration, I wrote an extension method to accomplish what I'm trying to do.</p>
  
  <pre><code>namespace System
  {
      public static class SystemExtensions
      {
          public static bool In&lt;T&gt;(this T needle, params T[] haystack)
          {
              return haystack.Contains(needle);
          }
      }
  }
  </code></pre>
  
  <p>Now, I can write shorter code:</p>
  
  <pre><code>if (someEnum.In(someEnum.Enum1, someEnum.Enum2, someEnum.Enum3))
    this.DoSomething();
  if (someInt.In(CONSTANT1, CONSTANT2))
    this.DoSomethingElse();
  </code></pre>
  
  <p>It feels dirty, however, to write my own method for something that I just can't find in the framework.</p>
  
  <p>Any help you folks can offer would be great,
  Thanks</p>
  
  <p>EDIT: Thanks everyone for the in-depth anaylsis.  I think I'll keep using my In() method.</p>