If the method referred to by an invocation target has the System.Diagnostics.ConditionalAttribute
attribute set one or more times on it on it, then evaluation of the expression depends on the conditional compilation constants defined at that point in the source file. Each instance of the attribute specifies a string which names a conditional compilation constant. Each conditional compilation constant is evaluated as if it was part of a conditional compilation statement; if the constant evaluates to True
, then the expression is evaluated normally at runtime, if the constant evaluates to False
, then the expression is not evaluated at all at runtime.
Note that the attribute is not legal on functions or interface methods and is ignored if specified on either kind of method. Thus, conditional methods will only appear in invocation statements.