Errors in C#

There are three types of errors in C# that can be occur in your application. These are:-
• Syntax Errors

• Runtime Errors or Exceptions

• Logical Errors

System Errors
Syntax errors occur due to ill-formed codes. The cause can be a misspelled keyword, improperly constructed statements, absence of punctuations, such as line terminators, etc. The resulting code cannot be until all of these errors are removed.
Example:
namespace ConsoleApplication1
{
	class Program
	{

	}
}
In this case, the keyword Class is misspelled as Class. Notice how the Visual Studio IDE highlights the error even before compilation starts. This is possible because of background compiling which is utilized in almost all modern Programming IDE’s.
Runtime errors or Exceptions
Runtime errors or Exceptions are erroneous situations in the runtime. The simplest example can be a division by Zero which results in a “Division by Zero” exception to be raised. These are different from Syntax errors in the sense that the compiler cannot detect these and hence the application compiles.
In the above example, the application halts due to a DivideByZeroException. Since, the compiler cannot determine the number that will be entered by the user, the error goes undetected. At runtime, the statement float Result = I / J; raises the DivideByZero exception, if the user enters 0 as the input for the second variable.
Logical Errors
Logical Errors are those where the application compiles and runs properly but does not produce the required output, i.e errors in the logic of the program. They are harder to detect because they don’t throw any kind of exception. The best way to deal through them is to use the debugger, watches and call stacks.