Switch 建構函式

定義

初始化 Switch 類別的新執行個體。

多載

Switch(String, String)

初始化 Switch 類別的新執行個體。

Switch(String, String, String)

指定的參數顯示名稱、描述和預設值,初始化 Switch 類別的新執行個體。

Switch(String, String)

來源:
Switch.cs
來源:
Switch.cs
來源:
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)

來源:
Switch.cs
來源:
Switch.cs
來源:
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 。 如果 Value 屬性不是由程式代碼或組態檔屬性所設定,參數defaultSwitchValue就是 參數的值。 如需詳細資訊, Switch(String, String) 請參閱 多載。

適用於