Share via


SwitchAttribute.SwitchName Properti

Definisi

Mendapatkan atau mengatur nama tampilan sakelar.

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

Nilai Properti

Nama tampilan sakelar.

Pengecualian

SwitchName diatur ke string kosong.

Contoh

Contoh kode berikut menampilkan nilai SwitchName properti untuk semua sakelar yang digunakan dalam rakitan. Contoh kode ini adalah bagian dari contoh yang lebih besar yang disediakan untuk TraceSource kelas .

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

Keterangan

Properti SwitchName harus cocok dengan DisplayName properti sakelar.

Berlaku untuk