0% found this document useful (0 votes)
13 views

Using Using Using Using Namespace Class Static Void String

The document appears to be code for handling custom exceptions in a C# program. It defines a MyException class that inherits from ApplicationException and includes a custom error message. A MyDigitalCalculator class contains an ADDMYNUMBER method that divides two numbers entered by the user, throwing a MyException if they are equal to prevent division by zero errors.

Uploaded by

Pratik Bhoir
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Using Using Using Using Namespace Class Static Void String

The document appears to be code for handling custom exceptions in a C# program. It defines a MyException class that inherits from ApplicationException and includes a custom error message. A MyDigitalCalculator class contains an ADDMYNUMBER method that divides two numbers entered by the user, throwing a MyException if they are equal to prevent division by zero errors.

Uploaded by

Pratik Bhoir
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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