SwitchAttribute(String, Type) 建構函式

定義

指定參數的名稱和型別,初始化 SwitchAttribute 類別的新執行個體。

public:
 SwitchAttribute(System::String ^ switchName, Type ^ switchType);
public SwitchAttribute (string switchName, Type switchType);
new System.Diagnostics.SwitchAttribute : string * Type -> System.Diagnostics.SwitchAttribute
Public Sub New (switchName As String, switchType As Type)

參數

switchName
String

參數的顯示名稱。

switchType
Type

參數的型別。

範例

下列程式代碼範例示範如何使用 SwitchAttribute 建構函式來建立 switch 屬性。 此程式代碼範例是針對 類別提供的較大範例的 TraceSource 一部分。

[SwitchAttribute("SourceSwitch", typeof(SourceSwitch))]
static void Main()
<SwitchAttribute("SourceSwitch", GetType(SourceSwitch))> _
Shared Sub Main()

備註

參數 switchName 應該符合 DisplayName 參數的屬性。

適用於