Pre-compiled commands for. NET Consolidation

Source: Internet
Author: User

. NET consolidation precompilation command Abstract: Pre-compilation, also known as preprocessing, is to replace some code text. Processing commands starting with #, such as copying the file code contained in # include, # replacement of the define macro definition, and Conditional compilation, is the stage of preparation for compilation, main Processing # pre-compiled commands. In C #, pre-compilation is also called preprocessing. It is used to replace the code text. Processing commands starting with #, such as copying the file code contained in # include, # replacement of the define macro definition, and Conditional compilation, is the stage of preparation for compilation, main Processing # pre-compiled commands. The following describes the pre-compiled commands in C #: 1. # define and # undef usage: # define DEBUG # undef DEBUG # define tells the compiler that I have defined a DEBUG symbol, which is similar to a variable but has no specific value, it can be regarded as a symbol. # Undef is the definition of this symbol. If the DEBUG symbol is not defined, # undef does not work; otherwise, # define does not work. Both must be placed before the source code. The order of the two depends on the code sequence: # define DEBUG # undef DEBUG is not defined. If the two are in another order, the compiler considers that DEBUG is defined 2. # if, # elif, # else, And # endif tell the compiler to control the process of compiling code. Consider the following code: # if DEBUG Console. write ("debug"); # elif RELEASE Console. write ("realse"); # else Console. write ("other"); # endif the above Code means that if DEBUG is defined, debug is output and RELEASE is defined, realse is output; otherwise, other is output. What if DEBUG and REALSE are defined? You can give it a try. 3. # warning and # error indicate whether a warning or error message is returned by the compiler. Except for the error message, compilation stops. Refer to the following code: # if DEBUG ------> if the current DEBUG status is selected as DEBUG, the default value is # define # warning "the current status is Ddbug" # elif RELEASE ------> If the release status is selected, this is indeed not the default value, I don't know if I tried it right # warning "now in Realse state" # else # error "And what state is clear" # endif 4. # region and # endregion constitute a code block. # line (This specified command is not clear, refer to MSDN) This command can change the file name and line number information displayed by the jian compiler in the warning and error messages, use # line default to restore the row to the default row number. The following example shows how to report two warnings associated with the row number. # Line 200 Command forces the row number to be 200 (although the default value is #7 ). The result of another line (#9) as the default # line command follows the normal sequence. Example 1: // preprocessor_line.cspublic class MyClass2 {public static void Main () {# line 200 int I; // CS0168 on line 200 # line default char c; // CS0168 on line 9} Example 2: The following example shows how the debugger ignores hidden rows in the code. When running this example, it displays three lines of text. However, when you set the breakpoint as shown in the example and press the F10 key to pass the code one by one, you will see that the debugger ignores hidden lines. Note that the debugger ignores the breakpoint even if it is set on the hidden line. Www.2cto.com // preprocessor_linehidden.csusing System; class MyClass {public static void Main () {Console. writeLine ("Normal line #1. "); // Set a break point here. # line hidden Console. writeLine ("Hidden line. "); # line default Console. writeLine ("Normal line #2. ");}}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.