Provides a simple on/off switch that can be used to control debugging and tracing output.
[Visual Basic] Public Class BooleanSwitch Inherits Switch [C#] public class BooleanSwitch : Switch [C++] public __gc class BooleanSwitch : public Switch [JScript] public class BooleanSwitch extends Switch
When the System.Diagnostics.BooleanSwitch constructor cannot find initial switch settings in the registry or in environmental variables, the new switch is set to disabled (false) by default. To enable a disabled switch, call the SetSwitchSetting method with a value other than zero ("0").
To find out if a switch is enabled or disabled, access the Enabled field.
For more information, see <DebugTopicTBD>.
Namespace: System.Diagnostics
Assembly: System.dll
The following example creates a BooleanSwitch which controls the debug output of MyMethod.
[Visual Basic]
Dim traceParams As BooleanSwitch Assign traceParams As BooleanSwitch("traceParams","tracing of function params") ... Public Function MyMethod(a As Integer, b As String) As String If traceParams.Enabled Then Debug.WriteLine "MyMethod( " & a & " , " & b & " ) called" End If ... End Function
BooleanSwitch Members | System.Diagnostics Namespace | Switch | TraceSwitch | Debug | Trace