O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Diagnostic Debugger Output

Another capability of the System.Diagnostics namespace is to interact with a debugger from inside your code. Samples include emitting diagnostic information about what your code is doing, which can be visualized in a debugger’s output window. Let’s take a look at some of those capabilities.

Revisiting the Debug class, notice the presence of Write and WriteLine methods. Using them, you can write information to the debugger. Just as with Assert calls, the calls to those methods are omitted from the assembly if it isn’t built using the DEBUG flag, so there’s no runtime overhead in release build binaries. An example is shown here:

private void ContactPaymentService(string account, decimal amount) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required