How to see the code where a variable changed in Watch window from Visual Studio

JeffinAtl 161 Reputation points
2022-06-06T17:21:07.653+00:00

I want to see the code where a variable is changed in the watch window from Visual Studio 2019.
I can see the watch window and variable on it but can't figure out which code makes that variable is changed.
Can I trace it?

Developer technologies | Visual Studio | Debugging
Developer technologies | C#
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anna Xiu-MSFT 31,056 Reputation points Microsoft External Staff
    2022-06-07T10:52:40.837+00:00

    Hi @JeffinAtl ,

    Welcome to Microsoft Q&A!

    For your requirement, please right-click on the variable in watch window and select the “Break When Value Changes”.
    If the value of variable is changed, the data breakpoint will stop at the code line after the value is changed.

    Sincerely,
    Anna
    *
    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.