Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Main(string[] args)
- {
- //Exception handling with C#
- int a = 0;
- int b = 5;
- int[] x = { 1, 2, 3 };
- try
- {
- int y = b / a;
- }
- catch(DivideByZeroException ex)
- {
- Console.WriteLine("Cannot Divide By Zero");
- }
- try
- {
- Console.WriteLine(x[12]);
- }
- catch(IndexOutOfRangeException ex)
- {
- Console.WriteLine("Index Out of bound");
- }
- Console.ReadKey();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement