SwitchAttribute.SwitchName 屬性

定義

取得或設定參數的顯示名稱。

public:
 property System::String ^ SwitchName { System::String ^ get(); void set(System::String ^ value); };
public string SwitchName { get; set; }
member this.SwitchName : string with get, set
Public Property SwitchName As String

屬性值

參數的顯示名稱。

例外狀況

SwitchName 設定為 null

SwitchName 是設定為空字串。

範例

下列程式代碼範例會顯示元件中所有參數的 SwitchName 屬性值。 此程式代碼範例是針對 類別提供的較大範例的 TraceSource 一部分。

SwitchAttribute[] switches = SwitchAttribute.GetAll(typeof(TraceTest).Assembly);
for (int i = 0; i < switches.Length; i++)
{
    Console.WriteLine("Switch name = " + switches[i].SwitchName);
    Console.WriteLine("Switch type = " + switches[i].SwitchType);
}
Dim switches As SwitchAttribute() = SwitchAttribute.GetAll(GetType(TraceTest).Assembly)
Dim i As Integer
For i = 0 To switches.Length - 1
    Console.WriteLine("Switch name = " + switches(i).SwitchName.ToString())
    Console.WriteLine("Switch type = " + switches(i).SwitchType.ToString())
Next i

備註

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

適用於