Demonstrate the Conditional attribute

image_pdfimage_print

   

// Demonstrate the Conditional attribute. 
 
#define TRIAL 
 
using System; 
using System.Diagnostics; 
 
public class TestAno { 
 
  [Conditional("TRIAL")]  
  void trial() { 
    Console.WriteLine("Trial version, not for distribution."); 
  } 
 
  [Conditional("RELEASE")]  
  void release() { 
    Console.WriteLine("Final release version."); 
  } 
 
  public static void Main() { 
    TestAno t = new TestAno(); 
 
    t.trial(); // call only if TRIAL is defined 
    t.release(); // called only if RELEASE is defined 
  } 
}