Visual Studio C# Code Snippets Overview


C# Code Snippets are very useful feature provided by Visual Studio IDE. The post Visual Studio 2012 IDE versions have unique coding experience where developer can use the code snippet (usually called as short form of the code) typed will insert the common code constructs/fragments. This helps rapid code development by minimizing the keystrokes. For example you want to create a new class then you would need to type “class” followed by class name and open the braces and close the braces. But if you use the C# code snippet by typing “class” followed by TAB key twice will create the class template automatically.

class: The Class

Visual Studio C# code snippets:

In Visual Studio, the Code Snippet Manager maintains C# code snippets. The Code Snippet manager can be invoked via menu Tools -> Code Snippets Manager or by hitting Ctrl + K, Ctrl + B short keys.

After clicking on the Code Snippets Manager menu option, the Code Snippets Manager window will open that shows all preconfigured code snippets for C# languages.

Code Snippet Manager also contains code snippets for HTML, ASP.NET MVC project and many more types. In addition to that you can create our own custom code snippets based on our requirements. At high level understanding, code snippets are configured in .snippet file which is the XML template. Once the snippet template is created, you can import the .snippet file using Import option in Code Snippet Manager. Further you can checkout how to create custom C# code snippets article for more details.

– Article ends here –

Summary:


C# Code Snippets makes developer life eazy by enabling less required key strokes to write code. This enforce developer to concentrate on the business logic rather than typing the template repeatedly. C# code snippets can also be extended by writing custom code snippet scripts.

Related Tags:

Share this:

We will be happy to hear your thoughts

Leave a reply