PrepAway - Latest Free Exam Questions & Answers

Which two actions should you perform?

An application is throwing unhandled NullReferenceException and FormatException errors.
The stack trace shows that the exceptions occur in the GetWebResult() method.
The application includes the following code to parse XML data retrieved from a web service.
(Line numbers are included for reference only.)

You need to handle the exceptions without interfering with the existing error-handling
infrastructure.
Which two actions should you perform? (Each correct answer presents part of the solution.
Choose two.)

PrepAway - Latest Free Exam Questions & Answers

A.
Option A

B.
Option B

C.
Option C

D.
Option D

Explanation:
A: The TryParse method is like the Parse method, except the TryParse method does not
throw an exception if the conversion fails. It eliminates the need to use exception handling to
test for a FormatException in the event that s is invalid and cannot be successfully parsed.
C: UnhandledException event handler
If the UnhandledException event is handled in the default application domain, it is raised
there for any unhandled exception in any thread, no matter what application domain the
thread started in. If the thread started in an application domain that has an event handler for
UnhandledException, the event is raised in that application domain.

3 Comments on “Which two actions should you perform?

  1. PK says:

    In Option A, you are returning 0 when Tryparse could not parse its input to an int. So the calling method will never know if 0 is intended result or result due to error in received xml
    So not sure, it it is a good idea to use TryParse here




    0



    0

Leave a Reply