Differents between error and exception in C#

An error is a mistake is coding on the part of the programmer, so the program won't give the desired result.

For exampile, in ASP.NET there are different types of error:

1. Configuration error: these error arise when the web.config or machine.config files are not formed properly.

2. Compilation error: raised during compilation due to mistakes in language syntax

3. Parser errors: caused by incorrect tays and other syntax error in the ASP.NET page.

An exception is a run-time error that may occur due to wrong input type or other circumstance. for example:

divide by zero, worng format, file not found, file used in another application, array out bonds, over flow, DBNULL cannot convert to int string etc.

Errors are not handled they have to fixed by the programmer.

Exceptions should be handled using exception handling code(try catch throw block) so that the application won't crash. and inform user that exception has occured. can show the description of the exception, the exception arised in which function and which line etc.

原文地址:https://www.cnblogs.com/Jenny90/p/2968872.html