Lecture Windows programming: Chapter 5 - Châu Thị Bảo Hà

Chapter 5 of lecture Windows programming introduce about debugging and error handling. In this chapter presents the contents: Introduction to the errors in program, debugging, error handling. Inviting you to refer. | Debugging and Error Handling Chapter 5 Ebook: Beginning Visual C# 2010, chapter 7 Reference: CSharp How to Program, part D Xem thêm trang 287_R Contents Introduction Debugging Error handling Slide 2 Introduction Errors in program: a program can have three types of errors: compile-time errors: The compiler will find syntax errors and other basic problems run-time errors: A problem can occur during program execution, such as trying to divide by zero, which causes a program to terminate abnormally logical errors: A program may run, but produce incorrect results, perhaps using an incorrect formula 1-3 Debugging Debugging is the process of finding and correcting logic errors in applications applications are executed in two ways: with debugging enabled (F5) or without debugging enabled (Ctrl+F5) Techniques debugging in nonbreak mode outputting debugging information: (), () debugging in break mode using Breakpoints Some windows in Debug\Windows: Autos, Locals, Watch demo Slide 4 Debugging in nonbreak mode: For example, the programmer might print the value of a variable when its value changes to determine whether the variable is assigned the correct value. Example 1: static void Main(string[] args) { int[] testArray = { 1, 2, 3, 4, 5 }; foreach (int k in testArray) { (k); } (); } Example 2: Remove selected items in listbox Example 3: Xem giá trị khởi tạo cho mảng chuỗi (null or “”) Example 4: Xem kết quả thực hiện hàm Split Error handling An exception is an indication of a problem that occurs during a program's execution format error, arithmetic overflow, out-of range array subscripts, division by zero, invalid method parameters running out of available memory, Your program should be able to handle these exceptional situations. This is called exception handling Slide 5 Error handling (cont.) int tu = ( ); int mau = ( ); int result = tu / . | Debugging and Error Handling Chapter 5 Ebook: Beginning Visual C# 2010, chapter 7 Reference: CSharp How to Program, part D Xem thêm trang 287_R Contents Introduction Debugging Error handling Slide 2 Introduction Errors in program: a program can have three types of errors: compile-time errors: The compiler will find syntax errors and other basic problems run-time errors: A problem can occur during program execution, such as trying to divide by zero, which causes a program to terminate abnormally logical errors: A program may run, but produce incorrect results, perhaps using an incorrect formula 1-3 Debugging Debugging is the process of finding and correcting logic errors in applications applications are executed in two ways: with debugging enabled (F5) or without debugging enabled (Ctrl+F5) Techniques debugging in nonbreak mode outputting debugging information: (), () debugging in break mode using Breakpoints Some windows in Debug\Windows: Autos, Locals,

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
217    72    2    09-05-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.