Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

c# debug

Posted on 2011-02-13
6
Medium Priority
?
321 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: 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: 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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

661 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