<p>In VB.NET I often <code>Catch…When</code>:</p>

<pre><code>Try
    …
Catch e As ArgumentNullException When e.ParamName.ToUpper() = "SAMPLES"
    …
End Try
</code></pre>

<p>Is there a C# equivalent to <code>Catch…When</code>?</p>

<p>I don't want to resort to using an <code>if</code> statement inside a <code>catch</code> if possible.</p>

There's no equivalent to
```
Catch…When
```
in C#. You will really have to resort to an
```
if
```
statement inside your
```
catch
```
, then rethrow if your condition isn't fulfilled:
```
```
try
{
    …
}
catch (ArgumentNullException e)
{
    if ("SAMPLES" == e.ParamName.ToUpper())
    {
        … // handle exception
    }
    else
    {
        throw;  // condition not fulfilled, let someone else handle the exception
    } 
}
```
```