ConditionalAttribute Constructor

ConditionalAttribute Constructor (String)


Initializes a new instance of the ConditionalAttribute class.

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

public ConditionalAttribute(
	string conditionString


Type: System.String

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

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

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");

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
© 2015 Microsoft