Bird
0
0

Which of the following is the correct syntax to catch an exception of type ArgumentOutOfRangeException?

easy📝 Syntax Q3 of 15
C Sharp (C#) - Exception Handling
Which of the following is the correct syntax to catch an exception of type ArgumentOutOfRangeException?
Acatch ArgumentOutOfRangeException ex { }
Bcatch (ArgumentOutOfRangeException ex) { }
Ccatch (ex ArgumentOutOfRangeException) { }
Dcatch ArgumentOutOfRangeException (ex) { }
Step-by-Step Solution
Solution:
  1. Step 1: Recall C# catch syntax

    The correct syntax requires parentheses around the exception type and variable: catch (ExceptionType variable).
  2. Step 2: Match syntax with options

    Only catch (ArgumentOutOfRangeException ex) { } uses the correct syntax: catch (ArgumentOutOfRangeException ex) { }.
  3. Final Answer:

    catch (ArgumentOutOfRangeException ex) { } -> Option B
  4. Quick Check:

    Correct catch syntax uses parentheses [OK]
Quick Trick: Always use parentheses around exception type in catch [OK]
Common Mistakes:
MISTAKES
  • Omitting parentheses in catch
  • Swapping exception type and variable order

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Sharp (C#) Quizzes