Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual studio equivalent of java System.out

What do I use in Visual Studio (C#) to perform the equivalent of Java's System.out.println( /*stuff*/ ) ?

Does the output from the command show in the Output window in the IDE?

I have a button on a webpage that calls a service which returns a string. I want to see what's in the string and have tried all the variations below and nothing ever shows up in the output. It also doesn't stop on the breakpoint so I can check if there are any results.

var service = new OTest.TylerAPI.APIWebServiceSoapClient(); results = service.OdysseyMsgExecution("<Message MessageType='FindCaseByCaseNumber' Source='APIMessage' ReferenceNumber='1' NodeID='1' UserID='1'> <CaseNumber>T4CV0043212010</CaseNumber></Message>", "NMODYSSEYMETRO"); System.Diagnostics.Debug.Write(results); 
like image 257
Leslie Avatar asked Jan 18 '11 17:01

Leslie


People also ask

How do you do system out Println in Visual Studio?

out. println: Press Cmd+Shift+D.


2 Answers

Try: Console.WriteLine (type out for a Visual Studio or Rider snippet)

Console.WriteLine(stuff); 

Another way is to use System.Diagnostics.Debug.WriteLine:

System.Diagnostics.Debug.WriteLine(stuff); 

Debug.WriteLine may suit better for Output window in IDE because it will be rendered for both Console and Windows applications. Whereas Console.WriteLine won't be rendered in Output window but only in the Console itself in case of Console Application type.

Another difference is that Debug.WriteLine will not print anything in Release configuration.

like image 84
nan Avatar answered Oct 05 '22 23:10

nan


Use Either Debug.WriteLine() or Trace.WriteLine(). If in release mode, only the latter will appear in the output window, in debug mode, both will.

like image 29
Femaref Avatar answered Oct 06 '22 00:10

Femaref