When you're debugging code in Visual Studio, you're going to end up setting breakpoints, watching variables, and maybe dumping information to a log file or the immediate window. Wouldn't it be nice if you could read some of it?
Too often, we wait until we're writing a log entry or trying to peer into the contents of a watched variable to worry about formatting objects. If you find yourself looking at a particular object or structure more than a couple times, though, consider overloading the ToString() method on that object. After all, nothing should be better suited to present a default format for an object than the object itself. Instantly, you'll find that logging and debugging become easier, because when you hover over an instance of that object, you're going to see a meaningful representation of the object.
Continue reading "Overload ToString() to make debugging easier"




![Reblog this post [with Zemanta]](https://i0.wp.com/img.zemanta.com/reblog_e.png?w=525)





