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 benefit of using interface in c#?
What are the return types in c#?
What is the use of parse in c#?
Is for loop faster than foreach?
What is dll hell, and how does .net solve it?
Why do we use stringbuilder in c#?
Can abstract class be instantiated c#?
Define satellite assembly in c#?
Can you pass parameters to destructors?
How many types of namespaces available in version4?
What are the benefits of using the aggregate method in linq?
List the two important objects of ado.net and also list the namespaces that are commonly used in ado.net to aid in connection to a database.
What is the difference between interface and abstract class in c#?
Can int be null c#?
What is difference between private and protected in c#?