How should I use debug.print in C#

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.
LVL 9
william007Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ee_rleeCommented:
try

Debug.WriteLine
0
ee_rleeCommented:
sorry should be
System.Diagnostics.Debug.WriteLine("test");
0
william007Author Commented:
Hi, I choose Debug>Start Debugging, I can't see the word test appear in anyway...
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

ee_rleeCommented:
maybe you have closed the immediate window

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

0
xPert_UmerCommented:
View... Other Windows... Command Window
Type:
immed
at the > prompt and press enter.  The Immediate Window will magically appear.
0
xPert_UmerCommented:

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
SolutionsCSCommented:
This will work perfectly : Console.WriteLine( "test" );
0
icrCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
william007Author Commented:
Thanks:)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.