simple question about .net debugging

in VB6 I used debug.print quite a bit. What is the equivalent to this in .net?

thanks.
LVL 5
jkwassonAsked:
Who is Participating?
 
raterusCommented:
System.Diagnostics.Debug.Write("hello bob")
0
 
YZlatCommented:
Debug.Write

Trace.Write
0
 
raterusCommented:
One option:

Page.Trace.IsEnabled = True 'alternatively you can set trace="true" in the <%@ Page %> directive at the top of your .aspx page
Page.Trace.Write("Something")

check the bottom of your aspx page after doing this.



0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
YZlatCommented:
The difference is that Debug.Write will only show up in a Debug mode, and not in the Release mode, and Trace.Write will show up in both. So if you use Trace.write, you will have to remove those statements before you'll switch to Release mode
0
 
jkwassonAuthor Commented:
ok, that is good info. I didn't know about the trace stuff, so that is good info.

I still have a problem with debug.write though...

I tried this code
page.trace.isenabled = true
page.trace.write("hello world")
debug.write("hello john")
trace.write("hello john")

on debug.write, the debug is underlined and the system tells me that "'debug' is not declared"

trace.write still does not write values to the immediate window.

What I am really interested in here is replicating the functionality in vb6 where I could do debug.write "the value of x is: " & x     and I would see "the value of x is 1" in the immediate window.  what does .net use in code to write a something out to the immediate window?

Thanks!
jk
0
 
jkwassonAuthor Commented:
ok, that worked. Shouldn't I be able to put imports system.diagnostics.debug at the top of the page and then only use debug.write("hello bob") in my code?  For some reason it will not work unless I do the full system.diagnostics.debug.write("hello bob")

thanks,
jk
0
 
raterusCommented:
Just put this at the top:

Imports System.Diagnostics

You're adding .Debug in the imports statement, and on top of that using Debug.Write(), to the compiler it looks like this
System.Diagnostics.Debug.Debug.Write("Whoops!")

0
 
jkwassonAuthor Commented:
ah, ok that makes sense. Thanks for your help!
0
 
jkwassonAuthor Commented:
increasing points for split
0
 
jkwassonAuthor Commented:
lol, I just realized both of those answers were from the same person...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.