The Conditional attribute setting in Compile parameter : Conditional Attribute « Attribute « C# / CSharp Tutorial






// csc /define:DEBUG MainClass.cs

using System;
using System.Diagnostics;  

public class MyClass {

  [Conditional("DEBUG")]
  public void OnlyWhenDebugIsDefined( ) {
    Console.WriteLine("DEBUG is defined");
  }
}



public class MainClass {

  public static void Main( ) {

    MyClass f = new MyClass( );
    f.OnlyWhenDebugIsDefined( );
  }
}








10.3.Conditional Attribute
10.3.1.The Conditional Attribute
10.3.2.Demonstrate the Conditional attribute
10.3.3.The Conditional attribute setting in Compile parameter