Switch 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
初始化 Switch 类的新实例。
重载
| Switch(String, String) | 初始化 Switch 类的新实例。 | 
| Switch(String, String, String) | 通过指定开关的显示名称、说明和默认值来初始化 Switch 类的新实例。 | 
Switch(String, String)
- 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.SwitchProtected 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
通过指定开关的显示名称、说明和默认值来初始化 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.SwitchProtected Sub New (displayName As String, description As String, defaultSwitchValue As String)参数
- displayName
- String
开关的名称。
- description
- String
切换描述。
- defaultSwitchValue
- String
开关的默认值。
注解
参数 displayName 用于设置属性的值 DisplayName ,参数 description 用于设置属性的值 Description 。 如果Value属性不是由代码或配置文件属性设置的,则 defaultSwitchValue 参数是开关的值。 有关其他信息, Switch(String, String) 请参阅重载。