55

I'm getting this message in watch box.
Actually, my expression doesn't have any side effect, and I need to re-evaluate it automatically each time. How can I achieve that?

jake
  • 1,661
  • 1
  • 21
  • 30
fithu
  • 2,361
  • 5
  • 18
  • 23
  • 2
    The debugger disagrees with you. I'm with the debugger, got nothing else to look at. – Hans Passant Nov 14 '10 at 19:36
  • 1
    @Hans, debugger just doesn't check at all. It only supposes "every method has side effects, every property doesn't". Both is wrong. – fithu Nov 14 '10 at 19:53
  • 2
    This should probably be tagged with C#. The ",ac" modifier in the accepted answer is only valid in that language. Sources: [Format Specifiers in C#](http://msdn.microsoft.com/en-us/library/e514eeby.aspx), [Format Specifiers in C++](http://msdn.microsoft.com/en-us/library/vstudio/75w45ekt.aspx) – jake Jul 31 '13 at 19:12
  • 1
    I have this problem for C++, so if there's a way to supress the message for C++ I would love to hear it! – uglycoyote Oct 31 '17 at 18:34
  • Possible duplicate of [Visual Studio: Make debugger aware that a function doesn't cause "side effects"](https://stackoverflow.com/questions/1049995/visual-studio-make-debugger-aware-that-a-function-doesnt-cause-side-effects) – David Dec 26 '18 at 17:39

1 Answers1

87

You can append ,ac to the watch expression to have it automatically refresh the value

x.ToString(),ac

See http://msdn.microsoft.com/en-us/library/e514eeby.aspx for more information and other format specifiers.

thanks to Scott Visual Studio: Make debugger aware that a function doesn't cause "side effects"

Himanshu
  • 31,810
  • 31
  • 111
  • 133
zproxy
  • 3,509
  • 3
  • 39
  • 45