SwitchAttribute Constructor (String, Type)


Initializes a new instance of the SwitchAttribute class, specifying the name and the type of the switch.

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

public SwitchAttribute(
	string switchName,
	Type switchType


Type: System.String

The display name of the switch.

Type: System.Type

The type of the switch.

The switchName parameter should match the DisplayName property of the switch.

The following code example shows the use of the SwitchAttribute constructor to create a switch attribute. This code example is part of a larger example provided for the TraceSource class.

[SwitchAttribute("SourceSwitch", typeof(SourceSwitch))]
static void Main()

.NET Framework
Available since 2.0
Return to top