It has been observed almost never that a plan runs correctly at its very initially try. Issues are very widespread whilst establishing a plan and are thought of as errors. The errors can be possibly compile time or run time.
Compile time errors are frequently syntax errors and are detected just before the execution of plan. Missing semicolons, Mismatch of brackets, misspelling of key phrases and identifiers, bad references and improper assignments are widespread compile time errors. Run Time errors are arise in the course of the execution of plan. These errors do not let the thriving execution of plan and sometime sales opportunities to undesired benefits. In modern day programming, run time errors are also called exceptions. Divide by zero, invalid typecasting, invalid references, incapability to entry a source are some of the run time errors. Run time errors are thought of additional harmful as compared to compile time errors. These are frequently owing the invalid logic and almost never owing to syntax.
C# provides a very efficient approach to cope with run time errors (Exceptions). Any time C# compiler encounters run time mistake, it results in an exception object and throws it. If exception is not caught and handled, the mistake message is exhibited and plan terminates promptly. To continue the execution of plan, even mistake has occurred the exception have to be caught and handled properly. In .Web, exceptions are occasions of the courses derived from Procedure.Exception.
Exception is dealing with is performed utilizing- try….catch….last but not least syntax. We enclose the code in attempt block, which is very likely to elevate the exception, followed by catch block. The catch block catches the exception thrown and handles it. Every single catch block has the code to cope with the exception properly. At conclude we create the last but not least block- specifying the code that is normally executed no matter of irrespective of whether or not the exception is thrown.
/////exception dealing with code
last but not least
///the code to be executed last but not least irrespective of whether exception occurred or not
A single attempt block can have several catch blocks, every handles the distinct exception. But only a person catch block is executed for every single attempt block, out of several catch blocks. When an exception is occurred, catch blocks are examined a person by a person till the acceptable is located, that can cope with the exception. If no unique catch block handles the exception, then only normal catch block is executed.