Increase your Coding Speed using Code Snippets in Visual Studio


Code Snippets are one of the coolest features of Visual Studio, which can help us to increase our coding speed multi-fold times.

Good Developers generally use shortcuts and tricks to type less and generate more code in less time.

Code snippets are ready-made snippets of code which we can quickly insert into your source code.

They are a great productivity boost & can make writing program code quicker, easier, and more reliable.

In Visual Studio IDE, we can bring up the code snippet menu in 3 different ways –

Press CTRL+K, CTRL+X and select the required snippet.Press TAB, TAB to invoke the code snippet.

CodeSnippetMenu

Press  CTRL K + CTRL B to bring up the Code Snippets Manager, where we can see all the code snippets and manage them.

CodeSnippetManager

Press CTRL+SPACE to view the completion list and then select the snippet shortcut from the list. Press TAB, TAB to invoke the code snippet.

Below are just handful of code snippets which we can use in our day to day development work –

Shortcuts Description
ctor Creates a constructor for the class
prop Creates an auto-implemented property declaration.
propfull Creates a property declaration with get and set accessors.
try Creates a try-catch block.
switch Creates a switch block.
foreach Creates a foreach loop.

CodeSnippet



Categories: C#, Performance, Visual Studio

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: