Archive for the 'Tips’n'Tricks' Category

Visual Studio 2010 Command Prompt Here

Real developers live on the command line. Way back in 1996, Microsoft released the Command Prompt Here Power Toy to ease their pain. Industrious developers who preferred the Visual Studio command prompt took it and adopted it to run a Visual Studio command prompt with all of the paths to Visual Studio and .NET tools [...]

The dangers of Macros

Another developer came to me with a problem today that he couldn’t figure out. He couldn’t believe what he was seeing in the debugger and needed a second set of eyes. He had a line of code like the following; return max( eRetVal, GetNumber() ); While debugging, he noticed that he was stepping into the [...]

Extending CopyHelper using Extension Methods

In my last two posts, I have been developing a small utility library to do the grunt work of copying data from an instance of one class to an instance of another type. The Copier class from my last post allows me to copy all public properties from one class to another class as long [...]

Extending CopyHelper using Generics

In my last post, I created a method that does the grunt work of copying data from an instance of one class to an instance of another type. I often find myself copying data between the properties of my data layer classes and those of my user interface like this. // Copy the data from [...]

Method to Copy Data Between Objects of Different Types

One thing that I find tiresome when using the various Model/View patterns is the constant copying of data between the model and the view. Too often, I find myself writing code like this to copy data between an ICustomer and an ICustomerView; // Copy the data from the customer to the view view.Address = customer.Address; [...]

Visual Studio Macro to switch between CPP and H files

I’ve been doing a lot of managed C++ programming lately and I had forgotten what a pain it is switching back and forth between the header file and source file.  Back in the days of Visual Studio 6 I had a macro that switched between the CPP and H file, so I went googling, but [...]

The Stopwatch Class in .NET

Do you ever find yourself using DateTime to time a section of code?  Do you have code like the following? DateTime start = DateTime.Now; // Perform a long process Thread.Sleep( 1968 ); DateTime end = DateTime.Now; TimeSpan duration = end.Subtract( start ); Console.WriteLine( “This process took {0} ms”, duration.TotalMilliseconds ); If you do, you should [...]

Quickly Find/Open a File in Visual Studio

Here is a cool Visual Studio feature that almost nobody knows about. If you want to open up a file in your solution, but can’t be bothered to dig down through your projects and folders to find it, try this, Click in the Find box in the toolbar, Type >of followed by a space, then [...]