Visit our site: Vist and Get Free Gifts

Learn To Build: Exception Objects In C#

Visit our site: Vist and Get Free Gifts

Visit our site: Vist and Get Free Gifts

Wednesday, February 12, 2014

Exception Objects In C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ExceptionObject
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = 10;
            int y = 0;
            int result;

            try
            {
                result = x / y;
                Console.WriteLine("The result is: {0}", result);
            }
            catch (System.DivideByZeroException e)
            {
                Console.WriteLine("Whoops! You tried to divide by zero!");
                Console.WriteLine(e.Message);
            }
            finally
            {
                Console.WriteLine("Just proving that this code always runs.");
            }

            Console.ReadLine();
        }
    }
}

Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home