The Conditional attribute setting in Compile parameter : Conditional Attribute : Attribute C# Examples


C# Examples » Attribute » Conditional Attribute »

 

The Conditional attribute setting in Compile parameter









    
//  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(  );
    }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Attribute
» Conditional Attribute