If we write return statement in finally block will it works
fine or throws any error?

Answer Posted / mahesh kotekar

Answer Is NO. We cannot have return in finally block...
we get the following error.
Control cannot leave the body of a finally clause
returns void, a return keyword must not be followed by an
object expression

try
{
First.DoSomething1();
First.DoSomething2();

}
catch (Exception)
{

throw;
}
finally
{ return 0; }

Is This Answer Correct ?    5 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

In Server how to check whether model has error or not in ASP.Net MVC

864


Where are the routing rules defined in an asp.net mvc application?

766


How we can handle the exception at controller level in ASP.Net MVC?

793


What are the new enhancements done in default project template of asp.net mvc 4?

789


What are actions in asp.net mvc?

798


What is MVVM design pattern?

796


What is meant by viewdata?

732


What are the two ways to add constraints to a route?

744


What are the components of the .net framework.

773


What happens when I install the .net framework 3.0? How can I upgrade if I already have the .net framework 2.0 installed?

757


Can we have enum in entity framework?

798


What is the greatest advantage of using asp.net mvc over asp.net webforms?

748


What are ajax helpers in mvc?

712


sql related question (outer join, left, right etc) array vs hashtable CRL sqldatareader vs dataset what is WPF, WCF, compare to WinForms Webservices Asp.net MVC vs WebForms?

3192


Is the following route definition a valid route definition? {controller}{action}/{id}

992