Can multiple catch blocks be executed for a single try statement

No.of Views870
Bookmarked0
By RRaveen  On 22 Dec 2010
emailbookmarkadd commentsprint
 

Answer:

No.if one catch block excuted, then it will directlly go the final block if final block has in method.

Sample Code

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

namespace ConsoleApplication1
{
    class TryCatch
    {
        public void SaveEmployee(string empID)
        {
            try
            {
                // few line of code here
            }
            catch (DllNotFoundException dex)
            {
                throw dex;
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}

above code only execute DllNotFoundException or Generic Exception if any exception occurred.

 
 
About Author
 
RRaveen
Occupation-Software Engineer
Company-TGS
Member Type-Gold
Location-Singapore
Joined date-03 Jun 2009
Home Page-codegain.com
Blog Page-www.codegain.com
- B.Sc. degree in Computer Science. - 4+ years experience in Visual C#.net and VB.net - Obsessed in OOP style design and programming. - Designing and developing Network security tools. - Designing and developing a client/server application for sharing files among users in a way other than FTP protocol. - Designing and implementing GSM gateway applications and bulk messaging. - Windows Mobile and Symbian Programming - Having knowledge with ERP solutions
 
 
Other popular Interview Questions On .NET Frameworks
^ Scroll to Top