ConditionalAttribute(String) Constructor
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
ทํางานร่วมกับเราใน GitHub
แหล่งที่มาสำหรับเนื้อหานี้สามารถพบได้บน GitHub ซึ่งคุณยังสามารถสร้างและตรวจสอบปัญหาและคำขอดึงข้อมูลได้ สำหรับข้อมูลเพิ่มเติม ให้ดูคู่มือผู้สนับสนุนของเรา