1.#define (通常和#if一起使用)
使用 #define 可以定义一个符号,并通过将该符号用作表达式传递给#if 指令,使该表达式的计算结果为 true
比如:
// preprocessor_if.cs #define DEBUG#define VC_V7 using System; public class MyClass
{ static void Main()
{
#if (DEBUG && !VC_V7)
Console.WriteLine("DEBUG is defined");
#elif (!DEBUG && VC_V7)
Console.WriteLine("VC_V7 is defined");
#elif (DEBUG && VC_V7)
Console.WriteLine("DEBUG and VC_V7 are defined");
#else
Console.WriteLine("DEBUG and VC_V7 are not defined");
#endif
}
}
输出:
DEBUG and VC_V7 are defined
备注:详细介绍请见MSDN
http://msdn.microsoft.com/zh-cn/library/ed8yd1ha(v=VS.80).aspx