Trace vs Debug in .NET BCL

后端 未结 7 1306
余生分开走
余生分开走 2020-12-02 11:58

It seems that the

  • System.Diagnostics.Debug, and
  • System.Diagnostics.Trace

are largely the same, with the notable exception that

7条回答
  •  情书的邮戳
    2020-12-02 12:43

    This is full difference between Trace and Debug: Both Debug and Trace use System.Diagnostics namespace.

    Debug

    • It uses Debug class.
    • It uses in debug build.
    • It uses the time of application development.
    • In Debug mode compiler inserts some debugging code inside the executable.
    • Debug class works only in debug mode.
    • Performance analysis cannot be done using Debug.
    • Debugging uses to find error in program.
    • For Debug we can use Debug.Write() method.
    • Debug runs in same thread as main program execute.

    Trace

    • It uses Trace class.
    • Trace statement includes by default when program compiled into released build.
    • Trace class is used for testing and optimization even after an application is compiled and released.
    • Trace class works in both case Debug mode as well as release mode.
    • Trace runs in different thread form main program execute thread.
    • For Trace we can use Trace.Write() method.
    • It uses time of application deployment.

    reference : csharp corner

提交回复
热议问题