Can I set a breakpoint when variable is getting a specific value in .NET?

前端 未结 7 1947
执念已碎
执念已碎 2020-12-04 23:29

I am using Visual Studio 2010, and I know this feature is available in C++.

I need to debug some code, that changes a variable to several values. I want to debug the

7条回答
  •  暖寄归人
    2020-12-05 00:03

    VSCode

    In VisualStudio Code, you can set conditional breakpoints as follows:

    1. Click in gutter to create a red-dot breakpoint

    2. Choose Debug from left-side toolbar (icon: circle-slash over bug)

    3. There are four sections: Variables, Watch, Call Stack and Breakpoints

    4. Expand Breakpoints section so you can see the breakpoints

    5. Right-Click on the desired breakpoint

    6. Choose Edit Breakpoint...

    7. Set your condition and press . For example:
      myvar == 1234
      or
      'stophere' in myvar
      etc

    References:

    https://code.visualstudio.com/docs/editor/debugging#_conditional-breakpoints

提交回复
热议问题