Solved

C# equivalent of System.out.println in Java

Posted on 2010-08-17
10
7,708 Views
Last Modified: 2013-12-17
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
Comment
Question by:guyneo
  • 2
  • 2
  • 2
  • +4
10 Comments
 
LVL 16

Accepted Solution

by:
burakiewicz earned 100 total points
ID: 33458526
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
 
LVL 4

Assisted Solution

by:avarmaavarma
avarmaavarma earned 100 total points
ID: 33458559
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
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 33458570
0
The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

 
LVL 85

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 100 total points
ID: 33458709
"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
 
LVL 29

Assisted Solution

by:anarki_jimbel
anarki_jimbel earned 100 total points
ID: 33459204
Just to clarify:

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

appears also in the OUTPUT window. I always use it :)
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 33459752
Interesting.  It doesn't appear in my Output window (only my Immediate)...  =\

I'm actually using VS2010...is this a version difference possibly?
0
 
LVL 29

Expert Comment

by:anarki_jimbel
ID: 33460691
At work here I have 2005 installed, can't check with 2010 now. So - version differences, I believe :)
0
 
LVL 8

Assisted Solution

by:Subrat (C++ windows/Linux)
Subrat (C++ windows/Linux) earned 100 total points
ID: 33461252
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
 
LVL 1

Author Comment

by:guyneo
ID: 33475290
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
 
LVL 16

Expert Comment

by:burakiewicz
ID: 33476391
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Convert datetime to time string 10 28
C# MVC Insert Multiple Row into DB 2 30
Need a simple RegEx to search for two words 27 41
VS 2017 18 30
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question