在 Visual Studio 中调试时如何将变量设置为 null

How to set variable to null when debugging in Visual Studio

在 Visual Studio 中的 Locals window 中,您可以在调试时更改变量的值。

但是,我似乎找不到将值设置为 null 的方法。当我键入 null 时,VS 只是将值设置回原始值。我也尝试过 CTL + 0,它在 SSMS 中有效,但在 VS 中无效。

我终于明白了。您必须通过一些代码直接 window 来设置它。

  1. 立即打开Window

  2. myVarible = null;

您将在调试中看到值更新为 null windows。