I am developing some projects in C# and Silverlight.
I am trying to print lines of code in order to debug, but Console.Write()
doesn't seem to work.
I've created a Silverlight Application, not a Console Application where Console.Write()
did work. How can I print in a console or in the output window in a Silverlight Application project?
println? printf() is used in c language to print something whereas System. out. println() is used in java.
You can make a templated println(T val) function which takes any type you like, ints, doubles, etc, and you can print them in that function. However, what you're requesting up there: "A string" + a this is an expression which will return a type. What you're doing here is adding a const char* and an int .
The only difference between println and print method is that println throws the cursor to the next line after printing the desired result whereas print method keeps the cursor on the same line.
System. out. println(“hello”) means it will print the hello and move cursor on next line. while return(hello) will return the value from the function that will use by the object.
Use System.Diagnostics.Debug.Write
to print in the debug output window.
See http://msdn.microsoft.com/en-us/library/system.diagnostics.debug.write.aspx
Using System.Diagnostics.Debug.WriteLine();
like Fox32 and VoodooChild mentioned did not work for me initially. Apparently my debugging wasn't working at all (breakpoints did not hit for example).
I was able to fix the debugging by using IE instead of FireFox (see Debugging Silverlight not hitting breakpoints)
As soon as that was fixed, the System.Diagnostics.Debug.WriteLine();
worked perfectly :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With