#define、#if、#else、#endif使用
编译符号有两种状态,要么被定义,要么不被定义,define和if正好配合使用,#define在每个源码文件的第一行定义,然后if可以根据该定义判断是否执行某段源码。
比如:
#define RUN
class Program
{
static void Main(string[] args)
{
#if RUN
Console.WriteLine("run this block");
#else//如果把第一行#define RUN删掉就只执行这段代码
global::System.Console.WriteLine("run other block");
#endif
}
}