public class Foo
{
public static List<long> myList = new List<long>() { 1,2,3 }
}
In another method:
var testList = Foo.myList;
If I put a breakpoint at the last line and inspect testList
it gives me different lengths from time to time.
When I use ToList()
on Foo.myList
it seems to behave correctly. But why?
Edit:
My problem was that I made an ajax call > modified Foo.myList
> new ajax call > fetched Foo.myList
again and got the modified value.