Exception Dealing with in C#

It has been observed rarely that a system runs properly at its really first attempt. Errors are really widespread though acquiring a system and are viewed as as faults. The faults can be either compile time or run time.
Compile time faults are typically syntax faults and are detected before the execution of system. Missing semicolons, Mismatch of brackets, misspelling of search phrases and identifiers, lousy references and inappropriate assignments are widespread compile time faults. Run Time faults are arise for the duration of the execution of system. These faults do not let the profitable execution of system and sometime prospects to undesired outcomes. In modern day programming, run time faults are also called exceptions. Divide by zero, invalid typecasting, invalid references, lack of ability to accessibility a source are some of the run time faults. Run time faults are viewed as far more unsafe as compared to compile time faults. These are typically because of the invalid logic and rarely because of to syntax.
C# delivers a really efficient system to tackle run time faults (Exceptions). Each time C# compiler encounters run time mistake, it results in an exception item and throws it. If exception is not caught and handled, the mistake concept is exhibited and system terminates quickly. To carry on the execution of system, even mistake has happened the exception will have to be caught and handled effectively. In .Web, exceptions are cases of the lessons derived from Process.Exception.
Exception is dealing with is finished making use of- try….catch….eventually syntax. We enclose the code in try block, which is very likely to raise the exception, followed by capture block. The capture block catches the exception thrown and handles it. Every capture block has the code to tackle the exception appropriately. At finish we publish the eventually block- specifying the code that is usually executed no matter of whether or not or not the exception is thrown.
Check out



/////exception dealing with code


///the code to be executed eventually whether or not exception happened or not

A one try block can have numerous capture blocks, just about every handles the precise exception. But only 1 capture block is executed for just about every try block, out of numerous capture blocks. When an exception is happened, capture blocks are examined 1 by 1 till the ideal is found, that can tackle the exception. If no particular capture block handles the exception, then only normal capture block is executed.