Solved

c# debug

Posted on 2011-02-13
6
313 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
Comment Utility
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
Comment Utility
Here's the video Tutorial fo using Breakpoint

Cheers!
0
 
LVL 62

Assisted Solution

by:Fernando Soto
Fernando Soto earned 100 total points
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:teera
Comment Utility
Hi himanshut

please insert video
0
 
LVL 10

Assisted Solution

by:himanshut
himanshut earned 200 total points
Comment Utility
0
 
LVL 7

Assisted Solution

by:mkobrin
mkobrin earned 100 total points
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

772 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

11 Experts available now in Live!

Get 1:1 Help Now