If I have code like
try
{
return;
}
catch
{
return;
}
finally
{
return;
}

from which block will the value will be returned. and try
has been executed without any error.

Answer Posted / jens

It won't; that construction isn't allowed. You can't have a
return in the finally clause. Once that is removed there is
no problem, right?

Try this, call it from some code that displays the result
and then uncomment the //for...-line and run again.
private int WeirdTry()
{
int foo = 10;
int result = 4;

try
{
//for (int i = 0; i < 100; i++) result = 1 /
(foo - i);
return result;
}
catch (Exception ex)
{
MessageBox.Show("Exception " +
ex.InnerException);
return result;
}
finally
{ MessageBox.Show("finally ");}
}

/Jens

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is an event in c#?

584


What kind of the information stored inside the assembly?

645


What is constants in c#?

487


What is difference between write and writeline?

550


What is a lambda expression in c#?

603






How jit (just in time) works?

587


Why are local variables stored in stack?

641


Which of the following API is used to hide a window?

627


What is jagged array in c#?

627


Is char * null terminated?

608


What does protected internal access modifier mean?

633


What are the 3 elements of delegation?

594


How long does it take to get a loop recorder put in?

553


Explain the serialization in .net

636


Give an example of a directcast.

590