In VB.NET I often Catch…When:
Try
…
Catch e As ArgumentNullException When e.ParamName.ToUpper() = \"SAMPLES\"
…
End Try
<
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
}
}