Exception handling with trying and catching
using System;
class MainClass{
public static void Main(){
Console.WriteLine("Before catch");
int Zero = 0;
try {
int j = 22 / Zero;
} catch (Exception e) {
Console.WriteLine("Exception " + e.Message);
}
Console.WriteLine("After catch");
}
}
Output Before catch
Exception Attempted to divide by zero.
After catch
|
HTML code for linking to this page:
Related in same category :
-
-
-
-
-
-
-
-
-
-
-
|