01-C # Getting Started (debugging and error handling)

Source: Internet
Author: User

Honestly, there is nothing to write in this chapter, and many of them are practical.

  • Debugging method

You can use Debug. WriteLine () and Trace. WriteLine () to input debugging information to the output window in the form. However, you have never used the debugging information. You can set the breakpoint more effectively:

You can right-click the breakpoint and set some conditions to determine whether the conditions are met before execution. When the breakpoint is reached, the program will interrupt execution, and a local variable information will appear below the window:

In the current state, the program will be executed Statement by statement based on F11, and the value of the variable will also change in the window of the local variable.

There are also Debug. Assert () and Trace. Assert () Functions with three parameters, as shown below:

            int[] myIntArray = { 1, 2, 3 };            int myInt = myIntArray[3];            for (int i = 10; i > 1; i--)            {                Console.Write(i);                Debug.Assert(i < 5,"the i not small 5","from main for");            }

The effect achieved by the function is similar to the following:

  • Error Handling

Use try... catch... finally. You can only use try and finally blocks without catch blocks, or have one try block and several catch blocks. If one or more catch blocks exist, finally blocks are optional; otherwise, they are required.

This is nothing to remember. In actual use, you can go back and view it as needed.

  • Conclusion

Finally ~~~ After reading the first seven chapters, I tried to use the learned knowledge to improve the previous procedures over the past one or two weeks. Then, hey, you can start with "C # Getting Started classic (version 6th.

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.