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.
Press CTRL K + CTRL B to bring up the Code Snippets Manager, where we can see all the code snippets and manage them.
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 –
|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.|