SwitchAttribute.SwitchType Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets or sets the type of the switch.

Namespace:   System.Diagnostics
Assembly:  System (in System.dll)

public Type SwitchType { get; set; }

Property Value

Type: System.Type

The type of the switch.

Exception Condition

SwitchType is set to null.

The following code example displays the value of the SwitchType property for all switches used in an assembly. This code example is part of a larger example provided for the TraceSource class.

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);

.NET Framework
Available since 2.0
Return to top