Exceptions · interview question
Which statements about exception handling in C# are true? Select all that apply.
Select all that applyMedium
Answer and explanation
Correct answer
- A. Catch specific exception types that you can actually handle.
- C.
catch (HttpRequestException e) when (e.StatusCode == HttpStatusCode.NotFound)is an exception filter. - D. Exception filters run before the stack is unwound.
Why
Exception filters (when) let you decide whether to catch without unwinding the stack. If the filter returns false, the stack (and debugger context) is preserved for outer handlers.
Test yourself on Exceptions
A free test with instant, explained results. No account needed.