Hi,

See how a very simple exception handling works with try-catch methods using C#.

using System;

class MainClass{

    public static void Main(){

        int divOne = 0;

        try {
            int ans = 79 / divOne ;
        }

        catch (Exception e) {
            Console.WriteLine("You got the exception-> " + e.Message);
        }

    }
}

Output- “You got the exception-> Attempted to divide by zero.”

🙂

 

One Comment

  1. momochi April 24, 2011 at 5:54 pm

    Finally, an issue that I am passionate about. I have looked for information of this caliber for the last several hours. Your site is greatly appreciated.

     

Leave a Reply

Your email address will not be published. Required fields are marked *

 

 

 

Theme by HermesThemes

Copyright © 2018 CoderzHeaven. All Rights Reserved

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.