How to use #if to check a preprocessor expression in C#

1 Answer

0 votes
#define DEBUG

using System;

class Program
{
  static void Main(string[] args)
  {
    #if (DEBUG)
        Console.WriteLine("DEBUG defined");
    #endif
  }
}



/*
run:

DEBUG defined

*/

 



answered Dec 14, 2020 by avibootz
edited Dec 14, 2020 by avibootz

Related questions

...