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: 
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)) { /* ... */ }

```
You could write an extension method

```
 public static bool In(this int value, int[] range)
    {
        return (value >= range[0] && value <= range[1]);
    }

```