Professional Documents
Culture Documents
using System;
class MyClass
{
static void Main(string[] args)
{
try
{
Console.WriteLine("Enter First no");
int x = int.Parse(Console.ReadLine());
Console.WriteLine("Enter Second no");
int y = int.Parse(Console.ReadLine());
int z = x / y;
Console.WriteLine(z);
}
catch (Exception e1)
{
Console.WriteLine(e1.Message);
}
finally
{
Console.WriteLine("i will execute even exception occurs");
}
}
}
============================
UserFriendly Error Messages:-it is difficult for the ensuser to understand
Technical Error Messages
so that the developer must display userfriendly Error messages
using System;
class MyClass
{
static void Main(string[] args)
{
try
{
Console.WriteLine("Enter First no");
int x = int.Parse(Console.ReadLine());
Console.WriteLine("Enter Second no");
int y = int.Parse(Console.ReadLine());
int z = x / y;
Console.WriteLine(z);
}
catch (DivideByZeroException)
{
Console.WriteLine("Denominator must not be 0");
}
catch (FormatException)
{
Console.WriteLine("Plz enter number");
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}