Started Exceptionhandling
This commit is contained in:
36
Exceptionhandling/Program.cs
Normal file
36
Exceptionhandling/Program.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Exceptionhandling
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
var calculator = new Calculator();
|
||||
var result = calculator.Divide(5, 0);
|
||||
|
||||
}
|
||||
catch (DivideByZeroException dx)
|
||||
{
|
||||
Console.WriteLine("You cannot divide by 0.");
|
||||
}
|
||||
catch (ArithmeticException ax)
|
||||
{
|
||||
Console.WriteLine("");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Sorry, an unexpected error occured. :" + ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user