Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

using using using using

System; System.Collections.Generic; System.Linq; System.Text;

namespace MyCustomizedException { class Program { static void Main(string[] args) { try { Console.WriteLine("Please Enter Neumerator"); int a =Convert.ToInt32(Console.ReadLine() ); Console.WriteLine("Please Enter Denomenator");

int b =Convert.ToInt32(Console.ReadLine() ); MyDigitalCalculator mydc = new MyDigitalCalculator(); mydc.ADDMYNUMBER(a,b); } catch (MyException ex) { Console.WriteLine(ex.Message); } } } class MyException : ApplicationException { public MyException(string myErrorMessage) : base(myErrorMessage) { } } class MyDigitalCalculator {

public void ADDMYNUMBER(int s, int y) { //int a = 4; //int b = 4; if (s == y) { throw (new MyException("Sorry We Cannot Divide Same Number")); } else { Console.WriteLine("Welcome Successful Operation Done..." + s / y); } } } }

You might also like