Tag Archives: Tips

Timing a Method in C#

Here’s a very quick way to check the performance of a block of code. I’m wrapping a System.Diagnostics.Stopwatch class and sending all timings directly to Debug.WriteLine(). Please be aware that this is a very simplistic approach, and does not guarantee … Continue reading

Posted in Tips and Tricks | Tagged , | 2 Comments

Using Shapes as a Resource in WPF

This post covers how to re-use a collection of WPF shapes by combining them into a resource. Start by creating the drawing using Expression Blend. This example using a combination of Ellipses, Rectangles and Paths to create the rounded triangle: … Continue reading

Posted in Tips and Tricks | Tagged , , | 1 Comment

Switch Statement Code Snippet

Another Visual Studio tip – a colleague of mine showed me the “switch” code snippet. It automatically builds a complete switch statement with a case for each value in an enumeration. This can really save some time. Here’s an example: … Continue reading

Posted in Tips and Tricks | Tagged , , | 1 Comment

Detecting the Debugger

I’ve just discovered that .NET has a very quick way to detect when the debugger is attached. This has been so handy the past few days, and it works both for WinForms and ASP.NET…

Posted in Tips and Tricks | Tagged , | Leave a comment

ASP.NET Register User Controls Globally

If you drag a user control onto a web page in design view, Visual Studio automatically adds a Register tag at the top of the page: This is fine if you only have a few controls on a couple of … Continue reading

Posted in Tips and Tricks | Tagged , | Leave a comment