Questions about preprocessing commands

Source: Internet
Author: User

After using the preprocessing command, you can refer to the msdn learning and practice with reference to the example. Record the problems encountered.

1. Pre-processing commands are not pre-defined

In debug mode, # debug is always true, and other pre-processing commands can be used even if commented out. If not stated in advance, the result is directly judged to be error-free but the result is false.

2. the console. writeline function cannot be used under release.

# 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"); // compilation error in release Mode
# Endif


But the same type can be used with # If # else # endif? As follows:

# If (XX)
Console. writeline ("XX defined ");
# Else
Console. writeline ("XX not defined ");
# Endif

However, this code can be normally executed in both Debug and release without pre-defined preprocessing commands.

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: 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.