#if (C# Reference)
ref:http://msdn.microsoft.com/en-us/library/4y6tbswk.aspx
1 // preprocessor_if.cs
2 #define DEBUG
3 #define MYTEST
4 using System;
5 public class MyClass
6 {
7 static void Main()
8 {
9 #if (DEBUG && !MYTEST)
10 Console.WriteLine("DEBUG is defined");
11 #elif (!DEBUG && MYTEST)
12 Console.WriteLine("MYTEST is defined");
13 #elif (DEBUG && MYTEST)
14 Console.WriteLine("DEBUG and MYTEST are defined");
15 #else
16 Console.WriteLine("DEBUG and MYTEST are not defined");
17 #endif
18 }
19 }
2 #define DEBUG
3 #define MYTEST
4 using System;
5 public class MyClass
6 {
7 static void Main()
8 {
9 #if (DEBUG && !MYTEST)
10 Console.WriteLine("DEBUG is defined");
11 #elif (!DEBUG && MYTEST)
12 Console.WriteLine("MYTEST is defined");
13 #elif (DEBUG && MYTEST)
14 Console.WriteLine("DEBUG and MYTEST are defined");
15 #else
16 Console.WriteLine("DEBUG and MYTEST are not defined");
17 #endif
18 }
19 }