using multiple catch block in programming

Raj_Chennai
Posted by Raj_Chennai under C# category on | Points: 40 | Views : 1017
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace dividebyzero
{
class Program
{
static void Main(string[] args)
{
int v2, v1,v3;

try
{
Console.WriteLine("Enter the number to perform divide operation");
v1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the number by which divide operation is to be performed");
v2= Convert.ToInt32(Console.ReadLine());
v3 = v1 / v2;
Console.WriteLine("Result is {0}", v3);
}
catch(DivideByZeroException de)
{
Console.WriteLine("Division by Zero occurs"+de);
}
catch (Exception ee)
{
Console.WriteLine(ee.Message.ToString());
}
finally
{
Console.WriteLine("Task completed");
Console.ReadLine();
}
}
}

}

Comments or Responses

Login to post response