Пример #1
0
 static void Main(string[] args)
 {
     using (Calculator calculator = new Calculator())
     {
         Console.WriteLine("{0} / {1} = {2}", 120, 0, calculator.Divide(120, 0));
     }
     Console.WriteLine("Program finising");
 }
Пример #2
0
        private static void doWork()
        {
            //Calculator calculator = new Calculator();

            //Console.WriteLine("{0} / {1} = {2}", 120, 15, calculator.Divide(125, 15));

            //Console.WriteLine("Program finishing.");

            using (Calculator calculator = new Calculator())
            {
                Console.WriteLine("{0} / {1} = {2}", 120, 0, calculator.Divide(125, 0));
            }

            Console.WriteLine("Program finishing");
        }
        static void Main(string[] args)
        {
            //Calculator calculator = new Calculator();
            //Console.WriteLine("{0} / {1} = {2}", 120, 15, calculator.Divide(120, 15));
            //Console.WriteLine("Program finishing");
            using (Calculator calculator = new Calculator())
            {
                Console.WriteLine("{0} / {1} = {2}", 120, 15, calculator.Divide(120, 15));
            }

            using (Calculator calculator = new Calculator())
            {
                //Exception
                Console.WriteLine("{0} / {1} = {2}", 120, 0, calculator.Divide(120, 0));
            }
            Console.WriteLine("Program finishing");
        }