BCL mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ] 1.0.5000.0 2.0.0.0 All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe. System.Attribute System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method | System.AttributeTargets.All, AllowMultiple=true) System.Runtime.InteropServices.ComVisible(true)

Indicates to compilers that a method is callable if and only if a specified pre-processing identifier has been defined on the method.

A , which has an associated condition , can be attached to the definition of a method, creating a . Thereafter, when a compiler encounters a call to that method, it might choose to ignore the call unless a compilation variable is defined at the site of the call, with a value that matches in a case-sensitive manner the supplied to the

.

Note that compilers might provide several techniques to define such compilation variables, such as:

compiler command-line switches (for example, /define:DEBUG )

environment variables in the operating system shell (for example, SET DEBUG=1)

as pragmas in the source code (for example, #define DEBUG, to define the compilation variable, or #undef DEBUG to undefine it)

CLS-Compliant compilers are permitted to ignore uses of the .

The following example demonstrates the use of with a particular compiler that supports the use of this attribute. The property of the current attribute is initialized as "DEBUG".

`using System; using System.Diagnostics; public class MyClass { [ConditionalAttribute("DEBUG")] public static void Display() { Console.WriteLine("Compiled with DEBUG"); } } public class TestCondition { public static void Main() { Console.WriteLine("How was this compiled?"); MyClass.Display(); Console.WriteLine("<eop>"); } }`

When this code is compiled with the compilation-variable DEBUG defined at the callsite, the output when run is

How was this compiled?

Compiled with DEBUG

<eop>

When this code is compiled without the compilation-variable DEBUG defined at the callsite, the output when run is

How was this compiled?

<eop>

- Constructor
  A that contains the pre-processing identifier that makes callable the target method of the current instance.

  Constructs and initializes a new instance of the class.

  This constructor initializes the property of the current instance using .

  0
  1.0.5000.0
  2.0.0.0
- Property
  System.String

  Gets the that contains the pre-processing identifier that makes callable the target method of the current instance.

  A that contains the pre-processing identifier that makes callable the target method of the current instance.

  This property is read-only.

  0
  1.0.5000.0
  2.0.0.0
0