语言

Switch 构造函数

定义

初始化 Switch 类的新实例。

重载

名称 说明
Switch(String, String)

初始化 Switch 类的新实例。

Switch(String, String, String)

初始化类的新实例 Switch ,指定开关的显示名称、说明和默认值。

Switch(String, String)

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

初始化 Switch 类的新实例。

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)

参数

displayName
String

开关的名称。

description
String

开关的说明。

注解

创建新 Switch 对象时,参数的值 displayName 用于查找初始开关设置。 默认值为空字符串 ("")。

在 .NET Framework 应用的 XML 配置文件中,可以添加开关并设置其值、删除开关或清除应用程序之前设置的所有开关。 执行应用程序时,不会检测到对配置文件的动态更改。 在配置文件更改生效之前,必须停止并重启应用程序。 配置文件的格式应如以下示例所示:

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

继承者说明

若要设置开关的值,请设置 SwitchSetting 构造函数中的属性。

另请参阅

适用于

Switch(String, String, String)

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

初始化类的新实例 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)

参数

displayName
String

开关的名称。

description
String

开关的说明。

defaultSwitchValue
String

开关的默认值。

注解

该 displayName 参数用于设置属性的值 DisplayName ,该 description 参数用于设置属性的值 Description 。 如果属性不是由代码或配置文件属性设置的defaultSwitchValue,则Value参数是开关的值。 有关其他信息, Switch(String, String) 请参阅重载。

适用于