Switch 建構函式
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
初始化 Switch 類別的新執行個體。
Switch(String, String) |
初始化 Switch 類別的新執行個體。 |
Switch(String, String, String) |
指定的參數顯示名稱、描述和預設值,初始化 Switch 類別的新執行個體。 |
- 來源:
- 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 構函式中設定 屬性。
另請參閱
適用於
.NET 9 和其他版本
產品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
- 來源:
- 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) 請參閱 多載。
適用於
.NET 9 和其他版本
產品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |