The short, simplified answer is that it will return nothing . The code breaks wherever an exception occurs and it flows down the stack until something catches it.
Even if you really catch the exception, the variable that you tried to initialize with the return value of the method will remain what it was before the method was called:
var i = 5;
try
{
i = MyMethodThatThrowsAnException();
}
catch
{
}
I should mention that you really should not worry about the return value of a function if it throws an exception. If so, then you are probably doing something wrong, for example, using exceptions as flow control .
Crono source
share