Use the Conditional attribute with define : Define : Preprocessing Directives C# Examples


C# Examples » Preprocessing Directives » Define »

 

Use the Conditional attribute with define









    
#define  USE_METHOD_1

using  System;
using  System.Diagnostics;

class  MainClass
{

    [Conditional("USE_METHOD_1")]
    public  static  void  Method1()
    {
        Console.WriteLine("In  Method  1");
    }

    public  static  void  Main()  
    {
            Console.WriteLine("In  Main");
        Method1();
    }
}
    
   
  
   



Output

In Main
In Method 1


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Preprocessing Directives
» Define