Yes it will, but not when it is about to leave the while, but just after the code in the try or catch
is done executing.
Do this will call finally?
Frage
suppose that i have this code. if exception is InvalidData, do this will call finally to clean resources.
while(CanWork){
try
{
....
}
catch (InvalidDataException e)
{
LogAction(false, e.Message, e.StackTrace);
break;
}
catch (Exception e)
{
LogAction(false, e.Message, e.StackTrace);
}
finally
{
if (insta != null)
{
insta.Disconnect();
insta.Dispose();
insta = null;
}
}
}
Lösung
Andere Tipps
Yes of course . finally
block always gets executed . Please refer this link for more details
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow