Exemple #1
0
        static void Main(string[] args)
        {
            TesterExceptions testes = new TesterExceptions();

            testes.Method1();

            try
            {
                double res = testes.DoDivide(1, 2);
                Console.WriteLine("Res = {0}", res);
                res = testes.DoDivide(0, 2);
                Console.WriteLine("Res = {0}", res);
                res = testes.DoDivide(1, 0);
                Console.WriteLine("Res = {0}", res);
            }
            catch (DivideByZeroException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (MyCustomException e)
            {
                Console.WriteLine(e.Message);
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            TesterExceptions testes = new TesterExceptions();
            testes.Method1();

            try
            {
                double res = testes.DoDivide(1 , 2);
                Console.WriteLine("Res = {0}",res);
                res = testes.DoDivide(0 , 2);
                Console.WriteLine("Res = {0}", res);
                res = testes.DoDivide(1 , 0);
                Console.WriteLine("Res = {0}", res);
            }
            catch (DivideByZeroException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (MyCustomException e)
            {
                Console.WriteLine(e.Message);
            }
        }