C#C
C#15mo ago
Merineth

✅ Exception handling..

namespace Calculator.Model
{
    internal class Division
    {
        public decimal Run(decimal number1, decimal number2)
        {
            if (number2 == 0)
            {
                throw new AlexDivideByZeroException();
            }

            return number1 / number2;
        }

    }
}


When the method Run encounters an instance where number2 == 0 i want it to throw an exception BUT i dont want the program to stop. How does that work?
Was this page helpful?