About This eBook by Bart De Smet

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

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) ...

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required