Learn how to walk through your code using breakpoints and debug operations to find logical errors in this video. Also, gain an understanding of why logical errors are more difficult to find than program exception errors.
[Instructor] In our code, … we can also have other types of logical errors. … Logical errors are only caught during program execution. … One type of logical error is dividing by zero. … The operation of dividing by zero is an invalid operation … and as a result, our program errors … and throws an exception. … Let's take a look at an example of this in code. … In this program, we have an int A that has the value of four … and int B that has the value of zero … and then, we divide the two values … and store the value in results. … Let's run this and see what happens. … So here, we get a system divide by zero exception. … We attempted to divide by zero. … This operation is invalid and the only way … to avoid this error is to not divide by zero. … But, we can capture this error … and handle it in a different way … with C sharp's exception handling features. … These features help you deal with unexpected … or exceptional situations that occur … when a program is running. … Exception handling uses the try, catch, …
- Debugging defined
- Working with breakpoints
- Inspecting values of variables
- Defensive programming
- Common C# errors
- Debugging challenges