#define DEBUG
#if (DEBUG)#endif
这样不行吗?

解决方案 »

  1.   

    先添加引用:
    using System.Diagnostics;下面的代码
    你可以在项目属性里修改条件编译常数设置为TRACE后,和TRACE;DEBUG两种情况看看
    public static int Main(string[] args) 
    {
    Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));

    Debug.AutoFlush = true;

    Debug.Indent();

    Debug.WriteLine("Entering Main");

    Console.WriteLine("Hello World.");

    Debug.WriteLine("Exiting Main"); 

    Debug.Unindent();
    return 0;

    }
      

  2.   

    如你所写
    #if DEBUG
    #endif
      

  3.   

    调试时,本身就定义了debug,所有,自接用
    #if DEBUG就可以了