Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

c# debug

Posted on 2011-02-13
6
Medium Priority
?
324 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 400 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 800 total points
ID: 34885606
Here's the video Tutorial fo using Breakpoint

Cheers!
0
 
LVL 64

Assisted Solution

by:Fernando Soto
Fernando Soto earned 400 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:teera
ID: 34885650
Hi himanshut

please insert video
0
 
LVL 10

Assisted Solution

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

Assisted Solution

by:mkobrin
mkobrin earned 400 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Screencast - Getting to Know the Pipeline

773 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