h1.post-title { color:orange; font-family:verdana,Arial; font-weight:bold; padding-bottom:5px; text-shadow:#64665b 0px 1px 1px; font-size:32px; } -->

Pages

Exception Handling

  •     It is a Errors,innocent Errors,silly errors.
  •     Programmer spends as much time to fixing errors as in programming.
Categorize of Errors:
1)Grammatical or Syntax errors.2)Linker errors.3)Run Time errors.
Grammatical or Syntax errors:
   it occurs when Syntax goes errors.
Linker errors:
   It occurs when we try to access some library function and for some reason or the other function ca not found out.
Run Time errors:
    It occurs at time of exception of the Program.
Common reasons for Exceptions:
1) Failing short of memory.2)Dividing value of Zero.3)Inability to open a file.
4)Exceeding the bound of an array.5)Attempting to initialize an object to an impossible value.
How to handle exception in C#.net?
1)The try block followed by one more catch blocks.
2)The try-catch blocks followed by finally block.

1)try-catch blocks:
try block contains code executed to raise an exception.
2)try-catch-finally blocks:
finally block used to perform clean up operation before the program ends.
thrown Statement:
   The thrown statement is used to thrown exception explicitly.

User Defined Exceptions:
  At such time we need to defined exceptions if the rules are violated.
  Our exception class should be derived from the System.Exception class.