Debugging and Error Handling in C#
Debugging is the process of identifying and fixing errors in a software program so as to ensure that it behaves in an intended manner. In the software development domain, such errors are commonly referred to as bugs. There are several debugging tools or debuggers that can be used for tracing the exact piece of code.
The use of debuggers ensures a systematic approach to problem or error resolution. It involves some commonly performed activities such as starting, pausing, stopping or restarting a program, setting breakpoints, tracing memory locations, etc.
Types of Errors:
Errors may be broadly classified into two categories:
1. Compile-time errors
2. Run-time errors
All syntax errors will be detected and displayed by the C# compiler and therefore these errors are known as compile-time errors.
Sometimes a program may compile successfully creating the .exe file but may not run properly. Such programs may produce wrong results due to wrong logic or may terminate due to errors such as stack overflow.