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

What is interface c#?

455


How to rotate an Image in C#?

578


Explain more on CLR

747


What does private void mean in c#?

536


What is a partial class in c#?

485






What is regex replace in c#?

504


Explain About delegates

592


Can you have more than one namespace in c#?

489


How do you escape c#?

504


What is cts, clr?

429


Ho we can see assembly information?

518


how dot net compiled code will become platform independent?

525


What is the difference between early binding and late binding in c#?

500


What is the default value of object in c#?

452


What is generic delegate in c#?

453