views:

279

answers:

1

There is a Contains() extension method on IEnumerable; In VB I am able to do this:

If New String() {"A", "B"}.Contains("B") Then
    ' ...
End If

What would be the equivalent of this in C#?

+3  A: 

It is the same idea in C#, using LINQ extension methods:

using System.Linq;
...

if (new string[] {"A", "B"}.Contains("B")) {
    ...
}
Greg
I knew it was that simple, the real problem was I tried this on an Empty Website Project and was missing a reference to System.Data.Linq. Thanks.
Kevin