Best Online Resource For Non-Resident Indians      SEARCH COOLNRI.COM
 HOME  FORUMS  PORTALS & REVIEWS  RECIPES  INDIAN RESTAURANTS  GROCERY  CLASSIFIEDS  MOVIES / TV  CHAT  NEWS  HOROSCOPE  PAINTINGS  CONTACT  LOGIN
Welcome Guest Search | Active Topics | Members | Log In | Register

How do I send out simple debug messages to help with my debugging? Options
mathewjustus
Posted: Thursday, April 30, 2009 10:47:42 PM
Rank: Member
Groups: Member

Joined: 4/18/2008
Posts: 0
Visual Studio offers tons of useful debugging features and allows you to step through your code line-by-line. However, there are times when you don’t want to step through your application, but want to make it output simple text strings with variable values, etc.

Enter the System.Diagnostics.Debug class and its Write* methods. By using the Debug class, you can output messages similarly to the way the Win32 API function OutputDebugString. However, the beauty of the Debug class is that when you build your application using the default Release configuration in Visual Studio, no code lines are generated for your Debug.Write* class. This means there’s no performance penalty for using the Debug class in release code.

To use the Debug class, simply add the “using System.Diagnostics;” statement to your C# code file, and call Debug.Write:

Debug.Write("Hello, Debugger!");In addition to Write, you have the possibility to call WriteIf, WriteLine and WriteLineIf. For example:

bool @this = true;
bool that = false;
Debug.WriteLineIf(@this || that, "A conditional Hello!");
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

COOLNRI.COM 2006-2012 |  TERMS OF USE |  PRIVACY STATEMENT |  SEARCH 
FinaMetric - Affordable Effective Project Management