共用方式為


Switch 建構函式

定義

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

多載

名稱 Description
Switch(String, String)

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

Switch(String, String, String)

初始化類別的新實例 Switch ,指定交換器的顯示名稱、描述及預設值。

Switch(String, String)

來源:
Switch.cs
來源:
Switch.cs
來源:
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.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 值。 defaultSwitchValue參數即為交換器值,若Value該屬性非由程式碼或設定檔屬性設定。 更多資訊請參見過載部分 Switch(String, String)

適用於