© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•17mo ago•
99 replies
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;
        }

    }
}
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
Run
encounters an instance where
number2 == 0
number2 == 0
i want it to throw an exception BUT i dont want the program to stop. How does that work?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Next page

Similar Threads

✅ Exception handling
C#CC# / help
17mo ago
❔ Exception Handling
C#CC# / help
3y ago
❔ Exception Handling
C#CC# / help
3y ago
❔ Exception Handling question
C#CC# / help
3y ago