This tip falls squarely into the category of simple, yet oh so useful. Visual Studio 2015 isn’t exactly new, but I am still discovering things that make it nice for debugging. That’s where I’ve spent a lot of my time this week, and one thing that has saved me is using Actions on breakpoints to print messages to the console. And surprise! You can do the same thing even when using auto-properties in Visual Studio 2015 without backing fields.
First, if you haven’t checked out Actions on breakpoints, go ahead and catch up from one of Falafel’s Visual Studio 2015 posts.
An automatic property may look like you can’t set a breakpoint, but you can. In this example we will put one on the setter. Position your cursor after the setter and use the context menu to add a breakpoint.
Printing the Value
Now, how can we print the value getting set to the console? If this were a property with a backing field, we would use the value inside the setter, right?
Well, we can still use the value keyword inside of our Action console statement. Yes, it will work! Intellisense agrees with me.
And voila – we can see the values being set in the console!
Did you learn something? Check out more of Falafel’s blogs covering Visual Studio 2015.
Latest posts by Falafel Posts (see all)
- Matching Complex Query String Rewrite Rule in IIS - March 22, 2017
- Disable Content Filters in Sitefinity - March 8, 2017
- On Sitefinity Custom Widget Caching - February 22, 2017
- Dynamic Content Detail Widget Templates in Sitefinity - February 8, 2017
- Using Google Services in UWP C# Apps – Part 2 - February 7, 2017