[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

How should I use debug.print in C#

Posted on 2008-01-27
9
Medium Priority
?
7,075 Views
Last Modified: 2012-06-27
In VB, we can use debug.print to print the text in a console, but how do we do the similar thing in C#? The objective is to test the written class.
0
Comment
Question by:william007
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 26

Expert Comment

by:ee_rlee
ID: 20753151
try

Debug.WriteLine
0
 
LVL 26

Assisted Solution

by:ee_rlee
ee_rlee earned 400 total points
ID: 20753156
sorry should be
System.Diagnostics.Debug.WriteLine("test");
0
 
LVL 9

Author Comment

by:william007
ID: 20753201
Hi, I choose Debug>Start Debugging, I can't see the word test appear in anyway...
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 26

Expert Comment

by:ee_rlee
ID: 20753212
maybe you have closed the immediate window

To display the Immediate window, choose Windows from the Debug menu and select Immediate.

0
 
LVL 4

Expert Comment

by:xPert_Umer
ID: 20753345
View... Other Windows... Command Window
Type:
immed
at the > prompt and press enter.  The Immediate Window will magically appear.
0
 
LVL 4

Expert Comment

by:xPert_Umer
ID: 20753347

private void button2_Click(object sender, EventArgs e)
{
StreamReader re = File.OpenText("c:\\MyFile.txt");
string input = null;
while ((input = re.ReadLine()) != null)
{
Debug.Print(input);
Debug.Write(input);
Debug.WriteLine(input);
}
re.Close();
}

Open in new window

0
 
LVL 4

Expert Comment

by:SolutionsCS
ID: 20753470
This will work perfectly : Console.WriteLine( "test" );
0
 
LVL 7

Accepted Solution

by:
icr earned 1600 total points
ID: 20753593
SolutionsCS - that will write to the Console, not the Debug Console. If you then run the code in a non-debug environment it will still print out, which isn't really what you want for debugging messages.

Debug messages appear in the Output window if you select "Show Output From Debug". If you want to see your debug messages without all the other cruft go to Tools->Options->Debugging->General and check "Redirect all Output Window text to the Intermediate Window" and, if the Intermediate Window is closed, follow xPert_Umer's instructions.
0
 
LVL 9

Author Comment

by:william007
ID: 20775527
Thanks:)
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…
In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.
Suggested Courses
Course of the Month9 days, 9 hours left to enroll

591 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