Throw Exception from a function
using System;
class MainClass
{
static void AFunction()
{
int Zero = 0;
int j = 22 / Zero;
}
public static void Main()
{
try
{
Console.WriteLine("efore Function");
AFunction();
}
catch (DivideByZeroException e)
{
Console.WriteLine("DivideByZero {0}", e);
}
}
}
Output efore Function
DivideByZero System.DivideByZeroException: Attempted to divide by zero.
at MainClass.Main()
|
HTML code for linking to this page:
Related in same category :
-
-
-
-
-
|