Saturday, December 1, 2007

Debug.WriteLine in C#

If you are used to using Debug.WriteLine in VB.NET, it is sometimes a little confusing when you try to do it in C# and it doesn't work. The trick is to say:

using System.Diagnostics;

at the beginning of the C# app, then the Debug.WriteLine will work as you expect.

You can get more detailed information on this subject from:


Sam said...

I was thrilled to learn of Debug.WriteLine a few months ago--it made life so much easier.

Peter said...

Thanks for the post.
I was trying to figure out where the Debug.WriteLine functions were.

Anonymous said...

This is great but does not always work. Visual Studio 2008 debugger is buggy! Another workaround however: simply use Console.WriteLine("your message here"); and then, when in debug mode (F5), the output to Console will appear in the Output tab for windows (assuming your program is a Windows Forms program and you are not using the Console to display), under the "Show Output from Debug" option (which should be the default)

Anonymous said...

'using System.Diagnostics;'

Exactly what I was looking for as a new .NET dev, thanks man.