Apply Your Knowledge

Exercises

12.1. Creating a Custom Trace Switch

The TraceSwitch and BooleanSwitch classes are two classes that provide trace switch functionality. If you need different trace levels or different implementations of the Switch class, you can inherit from the Switch class to implement your own custom trace switches.

In this exercise, you will learn how to create a custom switch. You will create a FactorialSwitch class that can be set with four values (Negative (-1), Off (0), Overflow (1), and Both (2)) for the Factorial Calculator form. The class will have two properties: Negative and Overflow.

Estimated time: 25 minutes

1.
Launch Visual Studio .NET. Select File, New, Blank Solution, and name the new project 316C12Exercises ...

Get MCAD/MCSD.NET Training Guide (Exam 70-316): Developing and Implementing Windows®-Based Applications with Microsoft® Visual C#™ .NET and Microsoft® Visual Studio® .NET 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.