Stack member not returning correct data
This is sort of weird... I have an app that uses a stack. I push an object onto it, then (in the same thread) call a method that pops it off.
When I run this in Visual Studio... it works as expected. In LINQPad 6... debug shows the stack properly after the push (ie I see the valid data)... then in the called method... the same stack is empty, Count property is 0... nothing there.
I looked at stack synchronisation... but this is in the same thread, just a few statements later, but this does include iterating the next "foreach" loop through a database query No threading here that I can imagine, but that seems the only possible explanation.
So, in psuedo-code, the structure is this: it's really very simple.
Stack mystack = new Stack();
..
.
var query = stuff.... // get results from a SQL CE database
foreach (var x in query)
{
if( x is entry)
mystack.Push(x) // here, mystack looks just fine...
else
GetNextEntry(z);
}
public GetNextEntry(z)
{
mystack.Pop(); // here... in LINQpad, mystack is empty... but in VS, it shows the pushed object from above
}
Any help appreciated.
T.
Comments
Dang... found the problem... I had declared a second local stack variable in LINQpad. D'oh !