Eigen exceptions maken
static int ResultaatBerekening(int getal)
{
if (getal != 0)
return 100 / getal;
else
throw new DivideByZeroException("BOEM. ZWART GAT!");
}
static void Main(string[] args)
{
try
{
Console.WriteLine(ResultaatBerekening(0));
}
catch(DivideByZeroException e)
{
Console.WriteLine(e.Message);
}
}Een eigen exception ontwerpen
Last updated
Was this helpful?