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

Why ref is used in c#?

474


What does using do in c#?

517


List the differences between method overriding and method overloading?

490


Explain the clr triggers?

526


What do you mean by the delegate in c#?

511






Which property do we set on a Combo Box to display data on it prior to setting the DataSource ?

538


Why do we need interface in c#?

504


Is type nullable c#?

523


Is string primitive?

498


What are the desktop applications?

469


What are access modifiers used for?

597


Explain the difference between proc. Sent by val and by sub?

477


What can we do to handle multiple exceptions?

555


What is the use of console readkey ()?

487


What is the use of nullable types in c#?

487