programming-examples/c-sharp/Exception/C# Program to Demonstrate DivideByZero Exception.cs

20 lines
423 B
C#
Raw Normal View History

2019-11-15 12:59:38 +01:00
/*
* C# Program to Demonstrate DivideByZero Exception
*/
using System;
class Program
{
static void Main()
{
try
{
int result = 15 / int.Parse("0");
Console.WriteLine(result);
}
catch (DivideByZeroException e)
{
Console.Write(e.Message);
Console.ReadLine();
}
}
}