Question: What is the equivalent in C# for Delphi's in syntax, like:

```

  if (iIntVar in [2,96]) then 
  begin
    //some code
  end;

```

Thanks

Answer: 
I prefer a method like defined here: [Comparing a variable to multiple values](https://stackoverflow.com/questions/2356949/comparing-a-variable-to-multiple-values/2357002#2357002)

Here's the conversion of Chad's post:

```
public static bool In(this T obj, params T[] arr)
{
    return arr.Contains(obj);
}

```

And usage would be

```
if (intVar.In(12, 42, 46, 74) ) 
{ 
    //TODO: Something 
} 

```

or

```
if (42.In(x, y, z))
    // do something

```
You can create this extension method:

```
public static class ExtensionMethods
{
    public static bool InRange(this int val, int lower, int upper)
    {
        return val >= lower && val <= upper;
    }
}

```

then you can do this:

```
int i = 56;
if (i.InRange(2, 96)) { /* ... */ }

```