Hi,

As you know an exception is an error that occurs during the runtime.
Here is a simple exception handling example using C Sharp/C#.

using System;

class MainClass{

    public static void Main(){
        int value= 0;
        try {
            int i = 7/value;
        }
        catch (DivideByZeroException e) // catching divide by zero exception
        {
            Console.WriteLine("DivideByZero {0}", e);
        }
        catch (Exception e) // catching any other exceptions
        {
            Console.WriteLine("Exception {0}", e);
        }
    }
}

🙂

 

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.