Home / Tips / Blog article: Visual Studio 2010 Code Generation With Intellisense

| RSS

Visual Studio 2010 Code Generation With Intellisense

May 27th, 2010 | 1 Comment | Posted in Tips

Visual Studio 2010 provides a nifty little feature which let’s you generate code from within the editor. In this post I will show you how to use this feature. Imagine that you are having a fantastic coding day and you are coding at 100mph. You have just realised that you need a class called car and you want to do it ninja style. Just type in this.

image

Visual studio displays Car in red because it cannot find a Type named Car. Put your cursor on Car and hit Ctrl + .

image

The smart tag gives you two options:

  1. Generate class for ‘Car’
  2. Generate new type…

If you select the first option, a new class is created for you in a new file and appropriately named Car.

The second option which is “Generate new type…” gives you more control over the code which will be generated.

image

In the dialog box you can choose Access (public or private) and you can also select if you’d like to generate a class, struct, interface or an enum. An option also exists down below to either add the newly generated code to an existing file or create a new file.

Pretty neat I think.

Leave a Reply 1002 views, 3 so far today |
Follow Discussion

One Response to “Visual Studio 2010 Code Generation With Intellisense”

  1. Mark Says:

    yeah that’s neat, another little time saver….”Add to existing File” shouldn’t be an option though :-)

Leave a Reply





Switch to our mobile site