In many cases, we hope that some debugging information will not be output, but some trace and debug functions will not be used. We just need to package a few words, so it will not run if it is not in the debug status.
Using system. diagnostics; Class XY {[conditional ("debug")] public static void debuglog (string in_string) {console. writeline (in_srting);} public static int main (string [] in_args) {debuglog ("this is a test"); return 5 ;}}
If (system. environment. stacktrace. tolower (). indexof (": Line")> = 0) console. writeline ("debug"); else console. writeline ("release ");
String buildtype; try {bool found = assembly. getexecutingassembly (). getcustomattributes (typeof (debuggableattribute), false). length> 0; buildtype = found? "Debug": "release";} catch {buildtype = "<error> ";}
# If debug then' run else # end if in the debug state