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
What is the difference between Java and .NET garbage collectors?
What is yield break in c#?
What is cshtml?
Can a class be protected in c#?
What is the difference between a field and a property in c#?
Why we use extension methods in c#?
What are sorted lists?
Explain the difference between pass by value and pass by reference.
How many types of serialization are there in c#?
What is an xsd file?
Explain the Different types of configuration files in .net?
What is difference between private and static constructor?
Explain the difference between boxing and unboxing.
Can you put two constructor with the same structure in a class?
Can I get the name of a type at runtime?