© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu
Quick Links
Easy Studies

  HomeSource Code DotNet ► C# ▼

Write Error Using Catch Block

Runtime errors occur at the time the program executes and can't be corrected. A programmer can, however, take preventive measures while coding the program, to handle runtime errors with the help of the try, catch, and finally keywords.

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

namespace exception
{
    class Program
    {
      
        public static void Main()
{
try
{
throw new DivideByZeroException("Invalid Division");
}
catch(DivideByZeroException e)
{
Console.WriteLine("Exception" );
    Console.ReadLine();
}
Console.WriteLine("Final Statement that is executed");
            Console.ReadLine();
}

 

        }
    }

 

SLogix Student Projects
bottom