using System;
namespace Exceptional_Handling
{
class Program
{
static void Main(string[] args)
{
int a = 10;
int b = 0;
try
{
Console.WriteLine("10/0 is:{0}", Division(a, b));
}
catch (DivideByZeroException ex)
{
Console.WriteLine("Division by zero leads to infinity which is undefined and your values throws {0} because you {1}", ex.GetType().Name, ex.Message);
}
finally
{
Console.WriteLine("Subscribe my youtube Channel Gray Frost");
}
Console.ReadKey();
}
static int Division(int numerator,int denominator)
{
if (denominator == 0)
{
throw new System.DivideByZeroException();
}
return (numerator / denominator);
}
}
}
namespace Exceptional_Handling
{
class Program
{
static void Main(string[] args)
{
int a = 10;
int b = 0;
try
{
Console.WriteLine("10/0 is:{0}", Division(a, b));
}
catch (DivideByZeroException ex)
{
Console.WriteLine("Division by zero leads to infinity which is undefined and your values throws {0} because you {1}", ex.GetType().Name, ex.Message);
}
finally
{
Console.WriteLine("Subscribe my youtube Channel Gray Frost");
}
Console.ReadKey();
}
static int Division(int numerator,int denominator)
{
if (denominator == 0)
{
throw new System.DivideByZeroException();
}
return (numerator / denominator);
}
}
}
Comments
Post a Comment