How to use #warning to check a preprocessor expression and display error message in C#

1 Answer

0 votes
#define DEBUG

using System;

class Program
{
  static void Main(string[] args)
  {
    #if (DEBUG)
         #error Turn off Debug
    #endif
  }
}



/*
run:

test.cs(11,0): error CS1029: #error: 'Turn off Debug'

*/

 



answered Dec 14, 2020 by avibootz
...