Solved

c# debug

Posted on 2011-02-13
6
314 Views
Last Modified: 2012-05-11
how can i see the value of  result on debug in vsual studio 2010 I am a beginner

 private void button1_Click(object sender, EventArgs e)
        {
            string url = "http://www.devtopics.com";
            string result = null;

            try
            {
                WebClient client = new WebClient();
                result = client.DownloadString(url);
            }
            catch (Exception ex)
            {
                // handle error
                MessageBox.Show(ex.Message);
            }

        }
    }
0
Comment
Question by:teera
6 Comments
 
LVL 23

Accepted Solution

by:
wdosanjos earned 100 total points
ID: 34885599
Just put a breakpoint on the line that contains the closing } for the method (put the cursor on that line and hit F9 to set the breakpoint).  Then run your program (F5).

Once the program breaks on the breakpoint set above. Right click on your 'result' variable, and select 'Quick Watch' to view the value.  (You can also hoover over the 'result' variable to view its content).

I hope this helps.
0
 
LVL 10

Assisted Solution

by:himanshut
himanshut earned 200 total points
ID: 34885606
Here's the video Tutorial fo using Breakpoint

Cheers!
0
 
LVL 62

Assisted Solution

by:Fernando Soto
Fernando Soto earned 100 total points
ID: 34885613
Hi teera;

Place a breakpoint on this line of code. Left click on the line so that the cursor is on the line and press F9

result = client.DownloadString(url);

Run the program and when execution gets to this line it will stop.
Place the cursor on the variable name result and right click and select from the context menu "Add Watch"
Then press F10
Then observe the value in the "Watch" window, you will also be able to see it in the "Locals" window.
You can then press F5 to continue executing the program.

Fernando
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:teera
ID: 34885650
Hi himanshut

please insert video
0
 
LVL 10

Assisted Solution

by:himanshut
himanshut earned 200 total points
ID: 34885667
0
 
LVL 7

Assisted Solution

by:mkobrin
mkobrin earned 100 total points
ID: 34885698
another option if you don't  want to put a break in the program is to output the result to a message box, just like you are doing with the exception:
private void button1_Click(object sender, EventArgs e)
        {
            string url = "http://www.devtopics.com";
            string result = null;

            try
            {
                WebClient client = new WebClient();
                result = client.DownloadString(url);
                MessageBox.Show(result);
            }
            catch (Exception ex)
            {
                // handle error
                MessageBox.Show(ex.Message);
            }

        }
    }
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now