Created
January 3, 2019 16:39
-
-
Save howellcc/284dc3e811710f9d73929a5a60f3d29a to your computer and use it in GitHub Desktop.
Visual Studio text expansion snippet for private properties with public accessor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | |
<CodeSnippet Format="1.0.0"> | |
<Header> | |
<Title>Private Property With Public Accessor</Title> | |
<Shortcut>proppriv</Shortcut> | |
<Description>Code snippet for a private property with a public accessor.</Description> | |
<Author>howellcc</Author> | |
<SnippetTypes> | |
<SnippetType>Expansion</SnippetType> | |
</SnippetTypes> | |
</Header> | |
<Snippet> | |
<Declarations> | |
<Literal> | |
<ID>type</ID> | |
<ToolTip>Property type</ToolTip> | |
<Default>string</Default> | |
</Literal> | |
<Literal> | |
<ID>property</ID> | |
<ToolTip>Property name</ToolTip> | |
<Default>MyProperty</Default> | |
</Literal> | |
<Literal> | |
<ID>field</ID> | |
<ToolTip>Backing field name</ToolTip> | |
<Default>myProperty</Default> | |
</Literal> | |
</Declarations> | |
<Code Language="csharp"><![CDATA[private $type$ _$field$; | |
public $type$ $field$ | |
{ | |
get { return this._$field$; } | |
set | |
{ | |
if(this._$field$ != value) | |
{ | |
this._$field$ = value; | |
} | |
} | |
} | |
$end$]]></Code> | |
</Snippet> | |
</CodeSnippet> | |
</CodeSnippets> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment