This should be simple enough. Here’s my one line of code that’s giving me trouble:
Point tp3 = new Point(0.0, 0.0);
And yet if I break directly after that and type “tp3” into the Immediate window, I get “The name ‘tp3’ does not exist in the current context.” What the heck is going on? I have much more code in this project than just that one line, but I’m not sure what could be affecting it. I’m literally breaking on the line directly after this one, and tp3 is nowhere to be seen. If I hover over tp3 while in break mode, I get nothing there either.
Does anyone know what could be causing this? Why isn’t C# letting me creating a Point??
Edit: I am using the System.Windows.Point struct, and I discovered that I was actually running in Release mode when I meant to be in Debug. Which, of course, was the issue, since tp3 was being garbage collected. Thanks everyone for the quick and accurate responses! I was about to pull my brains out. Yes, my brains.
Edit #2: Actually, as Maupertuis pointed out (pun completely intended), since Point is a struct it isn’t be garbaged collected, instead the compiler isn’t even allocating space for it in the first place since it isn’t used. Thanks Maupertuis!
If tp3 is no longer used it will be classed as Out Of Scope and subject to Garbage Collection.
Try adding something like
Point tempP = tp3;after your line, you should be able to see it then.