Export (0) Print
Expand All

ConditionalAttribute Constructor

Initializes a new instance of the ConditionalAttribute class, specifying the name of the attribute that enables the calling of the conditional method.

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

public ConditionalAttribute (
	string conditionString
)
public ConditionalAttribute (
	String conditionString
)
public function ConditionalAttribute (
	conditionString : String
)

Parameters

conditionString

A string that contains the preprocessing identifier that makes the target method of the current instance callable.

The following console application example demonstrates the use of ConditionalAttribute with a particular compiler that supports the use of this attribute.

[Conditional("CONDITION1")]
public static void Method1()
{
    Debug.Write("Method1 - DEBUG and CONDITION1 are specified\n");
    Trace.Write("Method1 - TRACE and CONDITION1 are specified\n");
}

[Conditional("CONDITION1"), Conditional("CONDITION2")]    
public static void Method2()
{
    Debug.Write("Method2 - DEBUG, CONDITION1 or CONDITION2 are specified\n");
}

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft