Link to home
Start Free TrialLog in
Avatar of william007
william007

asked on

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.
Avatar of ee_rlee
ee_rlee
Flag of Philippines image

try

Debug.WriteLine
SOLUTION
Avatar of ee_rlee
ee_rlee
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of william007
william007

ASKER

Hi, I choose Debug>Start Debugging, I can't see the word test appear in anyway...
maybe you have closed the immediate window

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

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

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

This will work perfectly : Console.WriteLine( "test" );
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks:)