Catch statement without exception variable
using System;
class MainClass
{
static void Main()
{
int x = 10, y = 0;
try {
x = x/y;
}catch (System.IndexOutOfRangeException) {
Console.WriteLine("catch clause");
} finally {
Console.WriteLine("finally clause");
}
}
}
Output Unhandled Exception: System.DivideByZeroException: Attempted to divide by zero.
at MainClass.Main()
finally clause
|
HTML code for linking to this page:
Related in same category :
-
-
-
-
-
-
-
-
-
-
-
|