Given this snippet of code:
// Get first key //
int? keyEDISecurity = this.WorkQueue.GetNextWorkItem();
// Done? //
while (keyEDISecurity != null)
// Write changes //
List<ISNLEditableObject> changedRows = this.WorkQueue.GetChangedRows((int)keyEDISecurity);
catch (Exception ex)
// Exception handling/logging code
// Remove all data for the KeyEDISecurity from work queue cache //
// Get next work item //
keyEDISecurity = this.WorkQueue.GetNextWorkItem();
This is implementation specific optimization.
When function is executed, all its variables are usually created on the stack at once. Even though the language does not permit to access them yet, they are there. This is why
null before it has even been declared.
When the variable goes out of scope, the language does not permit to use it again, but it's still there on the stack. Its value does not need to be changed to
null, because it won't be used anywhere. It will be waste of processor time. This is why value of
changedRows is preserved, even though, according to language rules, it must be destroyed (when it goes out of scope) and created again (when it is declared).
Debugger does not respect all language rules. In fact, it may even be confused by some constructs. When you try to get value of a variable, the debugger does not check if it is in scope etc.