Demonstrate the Conditional attribute : Attribute : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » Attribute »

 

Demonstrate the Conditional attribute









    

// 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 
  } 
}


           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» Attribute