code example:
#if DEBUG Console.WriteLine ("debug:11111111111"); #else Console.WriteLine ("release:222222222222"); #endif
In this code, if the run mode is DEBUG, the code outputs "debug:11111111111"
In this code, if the run mode is Release, the "release:222222222222" setting is output, DEBUG and Release are set directly in the project configuration if "Define debug constant (U)" is set in the project (Define debug Constant (U)) is unchecked, you can use debug code in debug mode. Create in debug code with properties----right--project---you can also add some special effects (you don't have to play the effects if the conditions are met), such as:
int i = 10 #if Debug Debug.Assert (i < 9 ); Console.WriteLine ( " debug:11111111111 " ); #else Console.WriteLine ( " release : 222222222222 #endif
If you run this code, there are special effects:
1. If the point retries, will automatically locate the error location, whether there is no breakpoint; 2. If the point is ignored, the next step is continued; 3. If the point is terminated, the software is shut down directly. PS: If setting figure 1 does not work, see if the configuration of release and debug is set in the Solution property page is Debug. You can restore it: 1. Configuration Manager, configuration Properties---Properties--right-click Solutions, configuration Managers 2. Build--Configuration Manager
C # test Code # if debug uses