在为局部变量赋值后,我设置了一个断点。变量的名称保持灰色,当我将鼠标悬停在它上面时我看不到它的值。这是有效的发现,但突然停止了。
如下面的代码所示,我设置了两个断点,一个是将两个局部变量相加的地方,另一个是在实例化表单时。调试器不会在第一个断点处停止,而是在第二个断点处停止。当我将鼠标悬停在任何局部变量上时,我无法识别该变量及其值。
int testVariable = 1;
int test2 = 3;
int test3 = 0;
test3 = testVariable+test2; //this is where the breakpoint is - note test3 is grayed out
MainForm main = new MainForm(); // this where the second breakpoint is which does work
main.Show();
Run Code Online (Sandbox Code Playgroud)