I'm trying to learn preprocessor directive, so I made a simple example like this:
using System; namespace learning { class Program { static void Main(string[] args) { #define DEBUG test(); } private void test() { #if DEBUG Console.WriteLine("Debug mode"); #elif RELEASE Console.WriteLine("Release mode"); #else Console.WriteLine("Debug and release don't defined"); #endif } } } but I got unfortunately this error:
Impossible to define or cancel defining the preprocessor symbols after the first token in the file
I take this example from a programming book, what is wrong?
update (my solution):
#define RELEASE using System; namespace learning { class Program { static void Main(string[] args) { #if DEBUG Console.WriteLine("Debug mode"); #elif RELEASE Console.WriteLine("Release mode"); #else Console.WriteLine("Debug and release don't defined"); #endif Console.ReadLine(); } } } printed result: Debug mode, but should be Release mode. What I did wrong?