Search code examples
visual-studiovisual-studio-2019

How to set variable to null when debugging in Visual Studio


In the Locals window in Visual Studio, you can change the value of a variable while debugging.

However, I can't seem to find a way to set the value to null. When I type null VS just sets the value back to the original value. I have also tried CTL + 0 which works in SSMS, but not in VS.


Solution

  • ** Update 2023 - As noted in the comments, my original answer is not working. (I have deleted that answer).

    I tested this again in VS 2022, and was above to set the value to null in the locals window. I just typed in null, without quotes. If the property is not nullable, you will get a dialog message from VS.

    enter image description here