Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the equivalent of System.out.println() in C#/Silverlight?

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?

like image 257
Lucía Avatar asked Feb 19 '11 17:02

Lucía


People also ask

Does Println work in C?

println? printf() is used in c language to print something whereas System. out. println() is used in java.

How do you write System out Println in C++?

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 .

What's the difference between System out print () and System out Println ()?

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.

Is return the same as System out Println?

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.


2 Answers

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

like image 97
Fox32 Avatar answered Oct 14 '22 20:10

Fox32


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 :)

like image 37
Deruijter Avatar answered Oct 14 '22 21:10

Deruijter