SiteMap  | About    

Can we use "continue" statement in finally block

C# Interview questions

A continue statement cannot exit a finally block . When a continue statement occurs within a finally block, the target of the continue statement must be within the same finally block. You cannot continue execution of the loop, because an uncaught exception will transfer control to another function, otherwise, a compile-time error occurs.

See also.....Difference between Exception and Error

What is the difference between: catch(Exception e){throw e;} and catch(Exception e){throw;}

The first throws a new exception which doesn't include the stack trace. The second does. Most times you want to preserve the stack trace. This means that if you use the first approach the stack trace of the exception will always start from this method and you will lose the original exception trace which could be disastrous for someone reading exception logs as he will never find out the original cause of the exception.

See also.....System level Exceptions Vs Application level Exceptions

Can multiple catch blocks be executed for a single try statement ?

VB.Net interview question and answers

You can have multiple catch blocks associated with a try block, but only a single catch block can ever handle your exception. Once the proper catch code executed, the control is transferred to the finally block and then the code that follows the finally block gets executed.

Can we create try without catch block ?

Yes, you can have a try block without a catch, but it is mandatory to have a finally block.

What is inner Exception ? interview question and answers

Inner exception is a property of exception class which will give you a brief insight of the exception, that is, parent exception and child exception details. It is used in cases when you want to surface a different exception than the one that your code caught but you don't want to throw away the original context. (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.