通过


SwitchAttribute(String, Type) 构造函数

定义

初始化类的新实例 SwitchAttribute ,指定开关的名称和类型。

public:
 SwitchAttribute(System::String ^ switchName, Type ^ switchType);
public SwitchAttribute(string switchName, Type switchType);
new System.Diagnostics.SwitchAttribute : string * Type -> System.Diagnostics.SwitchAttribute
Public Sub New (switchName As String, switchType As Type)

参数

switchName
String

开关的显示名称。

switchType
Type

开关的类型。

示例

下面的代码示例演示如何使用 SwitchAttribute 构造函数创建 switch 属性。 该代码示例是 TraceSource 类中的一个较大示例的一部分。

[SwitchAttribute("SourceSwitch", typeof(SourceSwitch))]
static void Main()
<SwitchAttribute("SourceSwitch", GetType(SourceSwitch))> _
Shared Sub Main()

注解

参数 switchName 应与开关的属性匹配 DisplayName

适用于