Bird
0
0

Which of the following is the correct syntax to catch a specific exception type in C#?

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

    In C#, to catch a specific exception, use catch (ExceptionType variableName) syntax.
  2. Step 2: Match options to syntax

    catch (Exception ex) { } matches the correct syntax with parentheses and variable declaration.
  3. Final Answer:

    catch (Exception ex) { } -> Option C
  4. Quick Check:

    Correct catch syntax = catch (Exception ex) [OK]
Quick Trick: Use parentheses around exception type and variable in catch [OK]
Common Mistakes:
MISTAKES
  • Omitting parentheses in catch
  • Placing variable outside parentheses
  • Using braces incorrectly in catch

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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