How to compare two methods in Visual Studio

November 5, 2014, (updated on September 15, 2015), 1 comment, Software Development

Sometimes I need to compare two methods, for example to check if they can be refactored into one. To avoid the time consuming step of copying the two methods into separate files and compare them, I recommend using the Visual Studio extension ClipboardDiff.

After installing the extension and restarting Visual Studio, open the menu Tools / ClipboardDiff Settings and set the path of your preferred diff tool. You can use the Visual Studio diff tool which will show the diff directly in the current Visual Studio instance:

  • Path to diff tool of Visual Studio 2012:

    C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\vsdiffmerge.exe

  • Path to diff tool of Visual Studio 2013:

    C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\vsdiffmerge.exe

  • Path to diff tool of Visual Studio 2015:

    C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\vsdiffmerge.exe

To compare two code blocks, select the first one and copy it (CTRL-C), then select the second one, right-click and run “Diff selection against clipboard” (CTRL-ALT-J).

Screenshot

Tweet about this on TwitterShare on FacebookEmail this to someoneShare on TumblrShare on LinkedIn

Tags: , ,

One response to “How to compare two methods in Visual Studio”

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax