Using snippet code in Visual Studio

by March 27, 2016 0 comments
[Warning - Newbie section]
Access your Code Snippets Manger by menu Tools / Code Snippets Manger.


Select Language and choose one code snippet to see. Example for this

Location:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC#\Snippets\1033\Visual C#\for.snippet

Description
Code snippet for 'for' loop

Shortcut
for

SnippetTypes
Expansion, SurroundsWith

Author
Microsoft Corporation

To use this, you type for and press twice Tab right after "for" (no space), Boom! A magic just happens!

for (int i = 0; i < length; i++)
{
             
}

Try it yourself and enjoy!

Update
Here is snippet for generating get set after name of properties. Save it as *.snippet and import to your VS.

<codesnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <codesnippet format="1.0.0">
        <header>
            <title>GetSet</title>
            <description>Inserts getter/setter shorthand code</description>
            <shortcut>gs</shortcut>
        </header>
        <snippet>
            <code language="CSharp">
                &lt;![CDATA[{ get; set; }$end$]]&gt;
            </code>
        </snippet>
    </codesnippet>
</codesnippets>


Happy coding!

An Nguyen

Developer

Sharing daily exciting lesson learned and posts about .NET, SQL Server, HTML, Javascript - jQuery, CSS - Bootstrap, SalesForce CRM, Kentico CMS and so on.

0 comments :

Post a Comment