Επεξεργασία

Κοινή χρήση μέσω


Switch Constructors

Definition

Initializes a new instance of the Switch class.

Overloads

Switch(String, String)

Initializes a new instance of the Switch class.

Switch(String, String, String)

Initializes a new instance of the Switch class, specifying the display name, description, and default value for the switch.

Switch(String, String)

Source:
Switch.cs
Source:
Switch.cs
Source:
Switch.cs

Initializes a new instance of the Switch class.

protected:
 Switch(System::String ^ displayName, System::String ^ description);
protected Switch (string displayName, string? description);
protected Switch (string displayName, string description);
new System.Diagnostics.Switch : string * string -> System.Diagnostics.Switch
Protected Sub New (displayName As String, description As String)

Parameters

displayName
String

The name of the switch.

description
String

The description for the switch.

Remarks

When you create a new Switch object, the value of the displayName parameter is used to find initial switch settings. The default value is an empty string ("").

Within the XML configuration file of a .NET Framework app, you can add a switch and set its value, remove a switch, or clear all the switches previously set by the application. Dynamic changes to the configuration file are not detected while the application is executing. You must stop and restart an application before changes to the configuration file take effect. The configuration file should be formatted like the following example:

<configuration>  
  <system.diagnostics>  
    <switches>  
      <add name="mySwitch" value="10" />  
      <add name="myNewSwitch" value="20" />  
      <remove name="mySwitch" />  
      <clear/>  
    </switches>  
  </system.diagnostics>  
</configuration>  

Notes to Inheritors

To set the value of the switch, set the SwitchSetting property in the constructor.

See also

Applies to

Switch(String, String, String)

Source:
Switch.cs
Source:
Switch.cs
Source:
Switch.cs

Initializes a new instance of the Switch class, specifying the display name, description, and default value for the switch.

protected:
 Switch(System::String ^ displayName, System::String ^ description, System::String ^ defaultSwitchValue);
protected Switch (string displayName, string? description, string? defaultSwitchValue);
protected Switch (string displayName, string? description, string defaultSwitchValue);
protected Switch (string displayName, string description, string defaultSwitchValue);
new System.Diagnostics.Switch : string * string * string -> System.Diagnostics.Switch
Protected Sub New (displayName As String, description As String, defaultSwitchValue As String)

Parameters

displayName
String

The name of the switch.

description
String

The description of the switch.

defaultSwitchValue
String

The default value for the switch.

Remarks

The displayName parameter is used to set the value of the DisplayName property, and the description parameter is use to set the value of the Description property. The defaultSwitchValue parameter is the value for the switch if the Value property is not set by code or by the configuration file attribute. See the Switch(String, String) overload for additional information.

Applies to