Zelf uitzonderingen maken
Zelf exceptions opwerpen
static int DoeIets(int getal)
{
if (getal == 0) {
// DivideByZeroException is ingebouwd
throw new DivideByZeroException("Getal is 0. Dit is niet voorzien.");
}
else {
return 100 / getal;
}
}
static void Main(string[] args)
{
try
{
Console.WriteLine(DoeIets(0));
}
catch(DivideByZeroException e)
{
Console.WriteLine(e.Message);
}
}Een eigen exception ontwerpen
Last updated
Was this helpful?