InVisualstudio2005AndVisualstudio2008, We enterPropEnterTabKey to intelligently insert a segmentCode, Very convenient. For example:
If you are too lazy, you can also create code segments that you frequently write to improve the efficiency of code writing.Visualstudio2005AndVisualstudio2008, Open the menuTools-code snippets Manager (CTRL + k, CTRL + B)You can viewCode snippetsLocation:
Create your ownSingletonCode segment:(Singleton. SNIPPET)
<? XML version = "1.0" encoding = "UTF-8" ?>
< Codesnippets Xmlns: xsi = "Http://www.w3.org/2001/XMLSchema-instance" Xmlns: XSD = "Http://www.w3.org/2001/XMLSchema" Xmlns = "Http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet" >
< Codesnippet Format = "1.0.0" >
< Header >
< Title > Singleton </ Title >
< Shortcut > Singleton </ Shortcut >
< Description > Creates a singleton class following the discussion on that post of mine:
Http://blogs.ugidotnet.org/piyo/archive/2005/09/14/Singleton_C_NET.aspx </ Description >
< Helpurl />
< Author > Simone chiaretta </ Author >
< Snippettypes >
< Snippettype > Expansion </ Snippettype >
</ Snippettypes >
< Keywords />
</ Header >
< Snippet >
< References />
< Imports />
< Declarations >
< Literal Editable = "True" >
< ID > Classname </ ID >
< Tooltip > Here the name of your Singleton class </ Tooltip >
< Default > Singleton </ Default >
< Function />
</ Literal >
</ Declarations >
< Code Language = "CSHARP" Kind = "Any" Delimiter = "$" > Public class $ classname $
{
Private Static readonly $ classname $ instance = new $ classname $ ();
Static $ classname $ ()
{
}
Public static $ classname $ getinstance ()
{
Return instance;
}
} </ Code >
</ Snippet >
</ Codesnippet >
</ Codesnippets >
TheHeaderThis section briefly describesSnippetsSuch as name, shortcut, author, and remarks. In <Snippets> Under a node,SnippetsAnd <Default> Specifies the default value of this attribute. And in the key part <Code>, Use <! [CDATA]> Method definedSnippetsIn$It is very easy to define each attribute by parameter name.
(You can use the editor or MicrosoftCodesnippetEditor,Download here)
ThenVisualstudio2005AndVisualstudio2008, Open the menuTools-code snippets Manager (CTRL + k, CTRL + B), Click Import, and select SaveSingleton. snippetFile Location.
EnterSingleton, And then pressTabTo insertSingletonMode class. The cursor automatically stops at the class name. (You can also right-click and selectInsert snippet...And then select your ownCodesnippetYou can.
You can also create customCodesnippets, Such as a class template,NunitTemplate, readXMLFile code segment, saveXML, ThrowExceptionCode segment,String. isnulloremptyTo improve the efficiency of writing code.
(Other Visual Studio skills: to do a good job, you must first sharpen the tool-Visual Studio usage Skills 1)
Vs2010 plug-in: snippet designer
There is a visualstudio2010 plug-in snippetdesigner. Select a piece of code, right-click"Export as snippetYou can easily manage and create snippet.