Click here to Skip to main content
15,886,422 members
Articles / Visual Studio
Tip/Trick

Visual Studio Tips - Breakpoints

Rate me:
Please Sign up or sign in to vote.
4.52/5 (7 votes)
28 Mar 2019CPOL1 min read 6.7K   2   5
Few under-utilized features of breakpoints in Visual Studio that you should be aware of

Most of us know about Breakpoints and how to use them, but there are a few under-utilized features of breakpoints that you should be aware of.

You can set a simple breakpoint in a number of ways:

  1. Move the cursor to the line you want to break on and hit the F9 key
  2. Right click on the line of code
  3. Clicking in the gutter

Once you have a breakpoint set, you can do a few things with it. First, you can disable it, if you don’t need the breakpoint right now, but think you might come back to it.

Image 1

You can also disable all breakpoints from Debug -> Disable all breakpoint. This is handy for when you need to run and get reset, then re-enable all breakpoints and start your debugging again.

You can also make the breakpoint conditional based on the value of a variable or any boolean expression (yes, you can use the No Side Effects formatter). This can be helpful if you want to break when the value of a variable is a certain value.

Image 2

You can also make the breakpoint conditional based on the number of times a breakpoint is hit. For example, you might know that the first time a breakpoint is hit isn’t interesting to your debugging scenario but every time after that is interesting. You could set hit count > 1.

Image 3

You can also filter your breakpoints to a single thread or to exclude a thread, either by name or id.

This article was originally posted at https://hutchcodes.net/2019/03/visual-studio-break-points

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United States United States
I’m a Software Engineer at Microsoft working on the Azure Portal. Before that I spent about 20 years developed various business applications at a number of different companies. I have a passion for writing clean, scalable code and sharing what I’ve learned with others.

I also help run the Casco Bay .Net User Group

Comments and Discussions

 
GeneralMy vote of 4 Pin
RojoEl1-Apr-19 11:39
RojoEl1-Apr-19 11:39 
GeneralRe: My vote of 4 Pin
Jeremy Hutchinson13-Apr-19 8:59
professionalJeremy Hutchinson13-Apr-19 8:59 
PraiseRe: My vote of 4 Pin
RojoEl14-Apr-19 14:21
RojoEl14-Apr-19 14:21 
QuestionA good introduction... Pin
charlieg29-Mar-19 2:18
charlieg29-Mar-19 2:18 
AnswerRe: A good introduction... Pin
Jeremy Hutchinson13-Apr-19 8:51
professionalJeremy Hutchinson13-Apr-19 8:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.