First: You need to change the debug method to debug
Code with #if DEBUG package
usingSystem;usingSystem.Collections.Generic;usingSystem.Text;usingSystem.IO;namespacesplitpackage{ Public Static classEnvconfig {StaticEnvconfig () {#ifDEBUGToolsPath=@"D:\workspace\shopstyle\tool";#elseToolsPath=environment.currentdirectory;#endif intRootidx = Toolspath.lastindexof (@"\"); if(Rootidx >0) {RootPath= Toolspath.substring (0, ROOTIDX); } } Public Static stringToolsPath {Get;Private Set; } Public Static stringTmplatefile {Get{returnPath.Combine (ToolsPath,@"template\default.pm"); } } Public Static stringRootPath {Get;Private Set; } Public Static stringModulepath {Get{returnPath.Combine (RootPath,"Module"); } } Public Static stringConfigpath {Get{returnPath.Combine (RootPath,"conf"); } } }}
The second type:
Using macro Definitions
#define DEBUG//C # Macro definition must appear before all code. Currently we only let the debug macro work.
Using System.Diagnostics; This package must be included
#defineDEBUGusingSystem.Diagnostics;namespacetestconsole{classToolKit {[ConditionalAttribute ("LI")]//the long notation of attribute name[ConditionalAttribute ("DEBUG")] Public Static voidMethod1 () {Console.WriteLine ("Created by Li, buged.11"); } [ConditionalAttribute ("LI")] [ConditionalAttribute ("Nobug")] Public Static voidMethod2 () {Console.WriteLine ("Created by Li, Nobug."); } [Conditional ("ZHANG")]//short notation of attribute name[Conditional ("DEBUG")] Public Static voidMethod3 () {Console.WriteLine ("Created by Zhang, buged.11"); } [Conditional ("ZHANG")] [Conditional ("Nobug")] Public Static voidMethod4 () {Console.WriteLine ("Created by Zhang, Nobug."); } } Static voidMain (string[] args) {toolkit.method1 (); TOOLKIT.METHOD2 (); Toolkit.method3 (); TOOLKIT.METHOD4 (); } }}
Two debug methods for C #