LP on .NET

June 10, 2009

Generating Method Stubs in Visual Studio

Filed under: .NET,Microsoft,technology,Visual Studio — Larry Parker @ 3:17 pm

I’ve been using Visual Studio for years and just stumbled upon a very useful feature – generating method stubs.  You can read more about it here, but say you’re in the middle of coding and want to call a method that you haven’t written yet.  That’s what I was just doing a few minutes ago, but instead of doing the usual and moving out of the current block of code in the editor to create a new method, I decided to just code the method call the way it seemed it should be.

Then I right-clicked on the method call for the unwritten method, and to my delight I saw this:

untitled

A Generate Method Stub menu item gets added to the context menu!  I clicked on it and the following code was automatically generated for me:

private static XElement TransformQueryElement(ushort queryNum, XElement origQueryElem)
{
    throw new NotImplementedException();
}

Exactly what I needed!  Thanks Microsoft.  🙂

Advertisements

2 Comments »

  1. Hah – way cool! Thanks for sharing.

    Comment by Wayne S. — June 10, 2009 @ 3:22 pm | Reply

  2. Great stuff — this will come in very handy. Like you, I’ve been using VS for years and I never really stumbled upon that option before.

    Thanks for sharing your find.

    Comment by Bruce — June 10, 2009 @ 3:39 pm | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: