Demonstrate the Conditional attribute : Conditional Attribute : Attribute C# Examples


C# Examples » Attribute » Conditional Attribute »

 

Demonstrate the Conditional attribute









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



Output

Trial version, not for distribution.


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Attribute
» Conditional Attribute