Freigeben über


SYSK 38: Visual Studio 2005 Code Snippets

Did you know that if you type prop and press Tab key two times, VS will create a property definition for you as follows:
      private int myVar;

      public int MyProperty
{
get { return myVar; }
set { myVar = value; }
}
The int, myVar and MyProperty will be highlighted.  As you change int to your data type (e.g. string) in the data member variable declaration, the VS will change it correspondingly in the property declaration.  Same applies to myVar.  Cool, hah?

For more code snippets, click on Tools -> Code Snippets Manager…

Special thanks to Gary Lee who brought this to my attention.

Comments

  • Anonymous
    January 11, 2006
    Didn't know that, just tried it, and that is pretty cool.
  • Anonymous
    January 17, 2006
    Yes, this is an extremely useful feature and I particularly like the ability to create my own code snippets (refer to http://msdn2.microsoft.com/en-us/library/ms165393.aspx).

    Talking of similar cool features, I would also recommend taking a look at 'Refactor' on the right-click menu for a class as well as 'Implement Interface' menu item.