Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 8759
  • Last Modified:

C# equivalent of System.out.println in Java

HI Guys,
I am newbie in C#.  So here is a dumb question
In java, I use system.out.println to print out the messages. These are very helpful in knowing whats going on. I am able to do this while running in Netbeans(IDE).
In C# I am using the VisualStudio 2005. I use Console.WriteLine but I don't see any message printed out while executing (debugging) the program from the IDE. Am I missing a window/ in the IDE? or using the wrong command?
thanks
0
guyneo
Asked:
guyneo
  • 2
  • 2
  • 2
  • +4
5 Solutions
 
burakiewiczCommented:
that only works for console apps.  you can use debug.print, but you need to add
using System.Diagnostics;  then you need to look in the output window.

 Debug.Print("test");
0
 
avarmaavarmaCommented:
If your application is a 'Console' App - you should see a DOS console popup with the output in there. If it is WinForms app, you can see the output by going to the 'View' menu (in Visual Studio) -and selecting 'Output'.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Mike TomlinsonMiddle School Assistant TeacherCommented:
"I use Console.WriteLine but I don't see any message printed out while executing (debugging) the program from the IDE."

Console.WriteLine() will appear in the OUTPUT tab.

To write things to the IMMEDIATE window you need to use System.Diagnostics.Debug.WriteLine().

Examples:

        private void button1_Click(object sender, EventArgs e)
        {
            Console.WriteLine("Appears in the OUTPUT tab");
            System.Diagnostics.Debug.WriteLine("Appears in the IMMEDIATE tab");
        }
0
 
anarki_jimbelCommented:
Just to clarify:

 System.Diagnostics.Debug.WriteLine("Appears in the IMMEDIATE tab");

appears also in the OUTPUT window. I always use it :)
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Interesting.  It doesn't appear in my Output window (only my Immediate)...  =\

I'm actually using VS2010...is this a version difference possibly?
0
 
anarki_jimbelCommented:
At work here I have 2005 installed, can't check with 2010 now. So - version differences, I believe :)
0
 
Subrat (C++ windows/Linux)Software EngineerCommented:
Console.WriteLine() is only take the cursor to the next line. You need to put some message there like Console.Writeline("Hello") to get the o/p message.
If not finding the console window follow the below steps. (if ur writting a console application)

1. Press Ctr + F5

If not solved,

Tools-> Options ->Debugging -> General -> Redirect all Output Window Text to the  immediate window
 Hope this may help!
0
 
guyneoAuthor Commented:
Thanks for all the responses Guys. This is certainly taught me some new stuff.
One clarification question.
if I am running in debug mode, and output window is not open.
What would be the Immediate window? what ever window is open at the bottom? Does it print in any other window/tab? or just in the output tab.
0
 
burakiewiczCommented:
the immediate window is its own window.  On the menu under debug>>window>> you should see the different ones immediate,output,breeakpoints
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
  • 2
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now