Detailed Answers

A1: The correct answers are A and D. The Debug and Trace classes share the same Listeners collection. Therefore, you should add a listener object either to the Trace.Listeners collection or to the Debug.Listeners collection. Answer B is not correct because this solution will generate double entries in the event log. Answer C is not correct because the newly created listener object is not attached to the Listeners collection of the Trace and Debug classes.
A2: The correct answer is B. The Assert method checks for the given condition and generates an error when the condition evaluates to false. Answer A is not correct because this code segment will generate an error only when the value of TotalShipments is not equal to 0. Answers ...

Get Developing and Implementing Windows®-Based Applications with Visual C#™ .NET and Visual Studio® .NET Exam Cram™ 2 (Exam 70-316) now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.