This article is a mirror article of machine translation, please click here to jump to the original article.

View: 19993|Reply: 0

[Source] C# preprocessor instructions

[Copy link]
Posted on 10/12/2016 9:28:48 AM | | |

C#'s preprocessor instructions are easy to recognize, and you can recognize them when you see #.

  What is the difference between it and other commands?

  The difference is that these commands never translate into executable code commands, but affect various aspects of the compilation process.

  What is it used for?

  When two versions of the code are planned to be released. That is, the basic version and the enterprise version with more versions can use the preprocessor instructions.

  When compiling the basic version, using preprocessing directives prevents the compiler from compiling code related to additional features.

  Preprocessor instructions can also be used when writing code that provides debugging information.

  The following describes the functions of the preprocessor instructions:

  #define和#undef

  #define用法: #define Debug

  Debug can be thought of as a declared variable, but this variable has no real value, only exists.

  #define单独用没什么意义, it is generally used in conjunction with #if.

  #undef用法: #undef Debug

  The function is to remove the definition of Debug. If the Debug symbol does not exist, this instruction has no effect. If the Debug symbol exists, the previous #define has no effect.

  #define与#undef声明必须放在C#源文件的开头位置, which is above the reference of the assembly.



  #if, #elif, #else和#endif

  Let's look at an example  






Previous:Modify the usage of the command terminator delimiter in MySQL
Next:System.Web.Optimization cannot be found in .Net 4.5
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com