在 VS 中,转到 Tools -> Code Snippet Manager 并选择 Visual c#。导航以显示路径,它应该与此类似:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC#\Snippets\1033\Visual C#
or
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC#\Snippets\1033\Visual C#
在更改其中的内容之前,我建议关闭 VS。创建一个名为“TheRegions.snippet”的新文件并插入:
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>TheRegions</Title>
<Shortcut>TheRegions</Shortcut>
<Description>Codesnippet</Description>
<Author>Authorname</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal Editable="false">
<ID>classname</ID>
<ToolTip>ClassName</ToolTip>
<Function>ClassName()</Function>
<Default>ClassNamePlaceholder</Default>
</Literal>
</Declarations>
<Code Language="csharp"><![CDATA[
#region Properties
#endregion
#region Initialization
public $classname$ ()
{
}
~$classname$()
{
}
#endregion
#region Events
#endregion
#region Methods
#endregion
]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
将该文件复制到位置,启动 VS 并键入“TheRegions”智能感知应该出现。