Today, I have discovered a VS plug-in, which has good functions and is recommended to you. Official http://www.devprojects.net/
Provides the following functions:
- Smart sensing!
- To call a Quick Command, press Ctrl + press Enter.
- Code generation using the same syntax as T4 and ASPX
- Edit code snippets in Visual Studio Editor
- Full access to Visual Studio automation objects
- FileCodeModel access, SmartFormat, code substitution, cursor location
- Over 100 useful commands
Official Website demonstration
CSDN download (including VS2008, 2010,11 installation package): http://download.csdn.net/detail/bdstjk/4329082
Download 115
The default shortcut after installation is ctrl + enter.
Start to use automatic Encoding
This section describes how to use automatic encoding. In this walkthrough, We will generate some properties of a class and be familiar with automatic coding to generate embedded code.
Create a new console application project
Place the cursor at the bottom of the class, just like the code below.
using System;using System.Collections.Generic;using System.Linq;using System.Text; namespace ConsoleApplication1{ class Program { static void Main(string[] args) { } } | <---- Set the cursor here}
Call the automatic encoding command input dialog box
Press Ctrl + Enter to Enter the dialog box. Written in"Int id string name Person class".
After you press enter, the class Person generates the property ID and Name, as shown below:
namespace ConsoleApplication1{ class Program { static void Main(string[] args) { } } public class Person { private int _id; private string _name; public Person() { } public int Id { get { return _id; } set { _id = value; } } public string Name { get { return _name; } set { _name = value; } } | } }
Enable Automatic encoding embedding
You can also directly call the editor.
Enter"String LastName p"After the last attribute, press Ctrl + Enter.
public string Name{ get { return _name; } set { _name = value; }}string lastName p
This will execute the get/set attribute generated by the "attribute" command.
private string _lastName;public string LastName { get { return _lastName; } set { _lastName = value; } }
Command PropertyAutomatic (PA)
This command will generate an automatic attribute. Enter string phone pa and press Ctrl + Enter to generate the following code:
public string Phone { get; set; }
Command PropertyIf (PIF)
This command will generate an attribute that is empty when the Instance value is
Enter Address HomeAddress pif and press Ctrl + Enter to produce the following code:
public Address HomeAddress{ get { if (_homeAddress == null) { _homeAddress = CreateHomeAddress(); } return _homeAddress; }}
Override ToString Method
Now let's rewrite the ToString method to return the format representation of a class attribute.
Set the cursor and execution in the classTostrCommand.
This will override the ToString () method in our class.
override public string ToString() { string str = String.Empty; str = String.Concat(str, "Id = ", Id, "\r\n"); str = String.Concat(str, "Name = ", Name, "\r\n"); str = String.Concat(str, "LastName = ", LastName, "\r\n"); return str; }
Instantiate the Person class
Let's use another command to instantiate the default value of the class.
Main method,
Enter Person ci and press Ctrl + Enter to produce the following code:
class Program{ static void Main(string[] args) { Person person = new Person(); person.Id = 9999; person.Name = "Name"; person.LastName = "LastName"; }}
Of course there are many other shortcut keys:
(1) if else shortcut, directly enter ife and press ctrl + enter
(2) For the if shortcut, enter if directly, and press ctrl + enter (in fact, the one that comes with VS is also good. directly enter it and press the tab key)
(3) create a constructor, enter c in a class, and press ctrl + enter
(4) create a private member, <Class Name> <member name> f, and press ctrl + enter
(5) create a method, <type> <Method Name> m, and press ctrl + enter
(6) create a private method, <type> <Method Name> mp, and press ctrl + enter
(7) create a static method, <type> <Method Name> MS, and then press ctrl + enter
(8) create a private method, <type> <Method Name> msp, and press ctrl + enter
(9) only create attributes without creating corresponding members and only get, enter <type> <member name> pm in the class, and press ctrl + enter
(10) create a get-only property and its members, <type> <member name> p g, and press ctrl + enter
(11) Create attributes and members with both get and set, <type> <member name> p, and press ctrl + enter
(12) instantly write Console. WriteLine ();, <content to be output> cw, then press ctrl + enter
(13) try catch. enter tc and press ctrl + enter.
(14) try catch final shortcut, enter tcf directly, and press ctrl + enter
......
There are many other features to be found. Remember to share them.
My CSDN blog: http://blog.csdn.net/bdstjk