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
Why we use anonymous methods in c#?
What is a boolean c#?
what is .NET framework architecture ??
How to exclude a property from xml serialization?
What are the different states of a thread?
What is lastindexof c#?
When a Static Constructor is called in a Class?
Write one code example for compile time binding and one for run time binding? What is early/late binding?
How do I do implement a trace and assert?
What is console read in c#?
How can you force derived classes to provide new method implementations for virtual methods?
What tool we have to use to install assembli in gac folder.
Is an array an object c#?
Between windows authentication and sql server authentication, which one is trusted and which one is untrusted?
Do loops c#?