Compile and debug features of Visual Studio 2005

Source: Internet
Author: User

Edit and Contiue Features

When you debug a program, you often encounter situations like this: In Debugging a large section of code, encountered a small error, such as the parameters of the assignment error, at this time, often hope that these small errors can be corrected immediately after, can continue to debug tracking, without ending the entire debugging process to modify. In Visual Studio 2003, we have to stop the current debugging, modify the wrong place, and recompile, which is inconvenient. In Visual Studio 2005, provides a new feature called "Edit and Continue", meaning that when you are debugging, encountered a small error need to modify immediately, you can edit, and then continue to debug, do not need to end the entire debugging process, when you modify, It is convenient for the debugger to compile automatically in the background and execute the newly modified code. Here is an example to illustrate.

Open Visual Studio 2005, use C # to build an WinForm form application, add a label label to a form, a text box, a button, as shown in the following figure, the function we want to implement is that when you enter some information in the text box, the click button pops up a message box, The information that you just entered is displayed.

If we write the code as follows, there is a small error, the TextBox1.Text content as a part of the string, so the user input information is not displayed.

private void button1_Click(object sender, EventArgs e)
{
  //Show welcome message
  MessageBox.Show("Welcome textbox1.Text to Edit and Continue.");
}

Now, if we encounter this error while debugging, we can use the Edit and continue feature to correct it.

First, press F7 to switch to Code view, set breakpoints in the MessageBox.Show line, then press F5 to run the program, when the text box input string, because set the interrupt, the cursor stops on the MessageBox.Show line, at this time, we can modify the code, modified to:

private void button1_Click(object sender, EventArgs e)
{
  MessageBox.Show("Welcome " + textbox1.Text +" to Edit and Continue.");
}

After the modification, continue to press F5 run, this time, will show the correct results, the following figure, and do not need to use the previous "Stop debugging" function to stop debugging and then modify the program.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.