C#中的预处理指令

  C#中,预处理指令(preprocessor directives)是不会执行的命令,只影响编译过程.
1. #region 和 #endregion        定义一组语句作为整体执行.
2. #define 和 #undef               定义符号和删除定义符号
3.#if, #endif, #else 和 #elif      条件预处理指令(conditional preprocessor directives)
4. #error 和 #warning             用于引发错误和警告.当发生错误时,编译器停止执行代码.当发出警告时,编译会继续编译.
  
 1 #define  Symbol1
 2 using  System;
 3 public   class  Class1
 4 {
 5  public static void Main()
 6  {
 7    #if Symbol1
 8      Console.WriteLine("Symbol1 is defined");
 9    #else
10      #warning Symbol1 is not defined
11    #endif
12  }

13}


你可能感兴趣的:(C#)