Define exception variable in catch statement
using System;
class MainClass
{
static void Main()
{
try
{
int y = 0;
y = 10/y;
} catch (DivideByZeroException e) {
Console.WriteLine("Message: {0}", e.Message);
Console.WriteLine("Source: {0}", e.Source);
Console.WriteLine("Stack: {0}", e.StackTrace);
}
}
}
Output Message: Attempted to divide by zero.
Source: main
Stack: at MainClass.Main()
|
HTML code for linking to this page:
Related in same category :
-
-
-
-
-
|