Sample code below gives an "Use of unassigned local variable 'resultCode'" when compiled:
string answer;
string resultCode;
try
{
resultCode = "a";
}
catch
{
resultCode = "b";
}
finally
{
answer = resultCode;
}
I would have thought the catch block above should catch all exceptions, and so that it was not possible for resultCode to be unassigned by the time the finally block is entered. Can anyone shed some light ? Thanks.
EDIT: Thanks all. This answer which quotes the documentation seems to answer it well: https://stackoverflow.com/a/8597901/70140