Bird
Raised Fist0

You want to create a custom exception that supports serialization for remoting. Which method should you override in your custom exception class?

hard🚀 Application Q8 of Q15
C Sharp (C#) - Exception Handling
You want to create a custom exception that supports serialization for remoting. Which method should you override in your custom exception class?
AGetObjectData
BToString
CEquals
DFinalize
Step-by-Step Solution
Solution:
  1. Step 1: Understand serialization in exceptions

    To support serialization, the exception class must override GetObjectData to add custom data to the serialization info.
  2. Step 2: Evaluate other methods

    ToString returns string representation, Equals compares objects, Finalize is destructor; none relate to serialization.
  3. Final Answer:

    GetObjectData -> Option A
  4. Quick Check:

    Override GetObjectData for exception serialization [OK]
Quick Trick: Override GetObjectData to support exception serialization [OK]
Common Mistakes:
MISTAKES
  • Confusing ToString with serialization
  • Not overriding GetObjectData when needed
  • Misusing Equals or Finalize methods

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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