共用方式為


ConditionalAttribute(String) 建構函式

定義

初始化 ConditionalAttribute 類別的新執行個體。

public:
 ConditionalAttribute(System::String ^ conditionString);
public ConditionalAttribute (string conditionString);
new System.Diagnostics.ConditionalAttribute : string -> System.Diagnostics.ConditionalAttribute
Public Sub New (conditionString As String)

參數

conditionString
String

字串,指定與此屬性相關聯之區分大小寫的條件式編譯符號。

範例

下列範例示範如何使用 建 ConditionalAttribute 構函式。 此範例是針對 類別提供的較大範例的 ConditionalAttribute 一部分。

[Conditional("CONDITION1")]
public static void Method1(int x)
{
    Console.WriteLine("CONDITION1 is defined");
}

[Conditional("CONDITION1"), Conditional("CONDITION2")]
public static void Method2()
{
    Console.WriteLine("CONDITION1 or CONDITION2 is defined");
}
<ConditionalAttribute("CONDITION1")> _
Shared Sub Method1(x As Integer)
    Console.WriteLine("CONDITION1 is defined")
End Sub

<ConditionalAttribute("CONDITION1"), ConditionalAttribute("CONDITION2")> _
Shared Sub Method2()
    Console.WriteLine("CONDITION1 or CONDITIOIN2 is defined")
End Sub

適用於