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.)

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.)

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.



Leave a Reply 3

Your email address will not be published. Required fields are marked *


PK

PK

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