SwitchAttribute.GetAll Method (Assembly)


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

Returns all switch attributes for the specified assembly.

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

public static SwitchAttribute[] GetAll(
	Assembly assembly


Type: System.Reflection.Assembly

The assembly to check for switch attributes.

Return Value

Type: System.Diagnostics.SwitchAttribute[]

An array that contains all the switch attributes for the assembly.

Exception Condition

assembly is null.

The following code example shows the use of the GetAll method to identify the 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