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.