Solved

c# debug

Posted on 2011-02-13
6
316 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 63

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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

Title # Comments Views Activity
HttpPostedFile 1 30
localhost: This site can’t be reached  localhost refused to connect. 2 220
Call Controller Action Method from ASPX 2 22
tableview is not updating 1 21
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

828 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