systemexception |
SYSTEM EXCEPTION
“System exception are those
exception that are predefined in system library of compiler, a programmer just
used it for exception handling”,
There are hundreds of system exceptions such as
n FormatException
Exception occurs when we try to invalid conversion format such as try to
change a character value to integer, double to string etc.
n
IndexOfOutRangeException
Exception occurs when the input enter value need more space then available
data type space.
n DivideByZeroException
Exception occurs when we are trying to divide any number by zero.
n NullReferenceException
n StackOverFlowException
n OutOfMemoryException
These type exceptions are predefined
in library, that’s why when this type of exception occurs in program due to run
time error our program terminate abnormally.
For example consider this program.
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. Console.WriteLine("enter a number");
6. int a = int.Parse(Console.ReadLine());
7. Console.WriteLine("enter second number");
8. int b = int.Parse(Console.ReadLine());
9. double c = a / b;
10. Console.WriteLine("the division is = {0}",c);
11. Console.WriteLine("end of the program");
12. Console.ReadKey();
13. }
14. }
15.
In this simple example we can see
that system exception can raise at line no. 6 that will be FormatException ,
line 8 also FormatException, at line no. 10 DivideByZeroException can occur,
and may be same different Exception possibly occur during run time that will
terminate our program at that stage without executing the next lines of, if
there is no use of Exception Handling.
0 comments:
Post a Comment
Please do not enter any spam link in the comment box