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

What are differences between entity framework and l2s? : Entity framework

647


what is csdl?

587


In .net compact framework, can we free memory explicitly without waiting for garbage collector to free the memory?

553


Does windows 10 need .net framework?

531


How would you deploy your old applications with .net framework 4.0? Are the old applications compatible?

484






explain lazy loading, eager loading, and explicit loading?

571


When will the .net framework 3.0 be released?

548


mention what is the difference between ado.net and classic ado?

571


Explain the difference between viewbag and viewdata in mvc?

542


what do you mean by table-per-type?

625


Is entity framework slow?

524


How we can add the css in mvc?

590


What is the role of the jit compiler in .net framework?

629


How we can invoke child actions in ASP.Net MVC?

580


What is the need of Action Filters in ASP.Net MVC

571