C# .NET – Displaying debug information in Debug compilation

If you want to output extra infromation in your code to see what is going on in problem situations and you only want to include it in debug compilations and not in Release version you can add a “Debug” Conditional attribute to a function and use that function to output data into your system output. There are many ways but this is a simple and straightforward way to do it:

private void DebugInfo(String info)
Response.Write(“</br>” + info);

The function and it’s content will be left out in Release compilation.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.