with this code, I don’t understand why, if the assignment of the variable in the finally block does not understand that ALWAYS will be assigned. I think that I do not have a valid option when the currency will not be assigned. If you know, it will be great to understand why. appreciate it!
Thank!
CurrencyVO currency;
try
{
if (idConnection.HasValue && idConnection != 0)
{
currencyConnection = client.GetConnection(idConnection.Value);
model.Connection = currencyConnection;
}
else
{
int providerUserKey = (int)Models.UserModel.GetUser().ProviderUserKey;
currencyConnection = client.GetConnection(providerUserKey);
}
currency = model.Currencies.SingleOrDefault(c => c.IdCountry == currencyConnection.idcountry) ?? new CurrencyVO();
}
catch
{
currency = new CurrencyVO();
}
finally
{
model.PublishedContainer.Currency = currency;
}
the error occurs on the finally block. If I pull it out of the finally block as follows:
} catch {
currency = new CurrencyVO();
}
model.PublishedContainer.Currency = currency;
It works great.
source
share