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 strong name assembly?
What is definition in c#?
Is a c# interface the same as a c++ abstract class?
what is difference between destruct or and garbage collection ?
What is the use of static members with example using c#.net.
Is a games console a computer?
How do I create a multilanguage?
How do namespaces work?
What is the max value of int32 in c#?
What is dll file in c#?
What is null propagation c#?
What are the uses of namespaces?
What is a c sharp?
What are bitwise logical operators?
How to put assembly in gac?