A Visual Studio snippet for a class with #region sections

Here is a simple snippet to add to Visual Studio if you want:

Place it here for Visual Studio 2010: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC#\Snippets\1033\Visual C#

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>classr</Title>
			<Shortcut>classr</Shortcut>
			<Description>Code snippet for class with prepopulated regions.</Description>
			<Author>Microsoft Corporation</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
				<SnippetType>SurroundsWith</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Declarations>
				<Literal>
					<ID>name</ID>
					<ToolTip>Class name</ToolTip>
					<Default>MyClass</Default>
				</Literal>
			</Declarations>
			<Code Language="csharp"><!&#91;CDATA&#91;class $name$
	{
	#region Member Fields
	#endregion
	
	#region Constructor
	/// <summary>
	/// The default constructor
	/// </summary>
	public $name$()
	{
	}
	#endregion
	
	#region Properties
	#endregion
	
	#region Functions
	#endregion
	
	#region enums
	#endregion
		$selected$$end$
	}&#93;&#93;>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>

2 Comments

  1. Justin says:

    this is great, thanks!
    I made a few changes. I changed region title Function to Method. I also added a region for Private (internal/protected etc) methods since i like to break up what is internally accessible vs external.

    Thanks!

Leave a Reply

How to post code in comments?

*