Đang chuẩn bị liên kết để tải về tài liệu:
Lecture Windows programming: Chapter 5 - Châu Thị Bảo Hà
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
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: Console.WriteLine(), Debug.WriteLine() 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) { Console.WriteLine(k); } Console.ReadKey(); } 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 = Convert.ToInt32( txtNumerator.Text ); int mau = Convert.ToInt32( txtDenominator.Text ); 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: Console.WriteLine(), Debug.WriteLine() debugging in break mode using Breakpoints Some windows in Debug\Windows: Autos, Locals,