Bewerken

Share via


ConditionalAttribute(String) Constructor

Definition

Initializes a new instance of the ConditionalAttribute class.

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

Parameters

conditionString
String

A string that specifies the case-sensitive conditional compilation symbol that is associated with the attribute.

Examples

The following example demonstrates how to use the ConditionalAttribute constructor. This example is part of a larger example provided for the ConditionalAttribute class.

[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

Applies to