Can we write try block without Catch Block in

In the previous example we have learnt how to handle exceptions at constructor level in Now i am going to explain can we use try block with out catch block in CSharp.Net.

Explanation: We can use try block with out catch block by declaring finally block which is syntactically correct in This is one of the best Interview Question

using System;

namespace ConsoleApp1
    class Program
        static void Main(string[] args)
                int i = 0, j = 1, result;
                Console.WriteLine("this is try block");

            //catch(Exception ex)
              //  Console.WriteLine(ex.Message);
                //Console.WriteLine("this is Catch block");
                Console.WriteLine("this is finally block");



If you have any queries or suggestions, please feel free to ask in comments section.
Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar