Demonstrate the Conditional attribute : Conditional Attribute « Attribute « C# / CSharp Tutorial






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








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