Code Snippets in Visual Studio in C sharp Arabic #70
Suggested Videos
Code Snippets in Visual Studio.
Code snippets are readly –make snippets of code you can quickly insert into your code.
1-keyword shortcut :CTRL K+X.
2-Right click and select “Insert Snippet ..” from the context menu.
3-Click on Edit –intellisense –Insert Snippet.
4-Use code snippets short cut . For example to use “ for loop ”code snippet, type “for”and press TAB key twice.
Once a code snippet is inserted . the editable fields are highlighted n yellow , and the first editable Field is selected automatically. Upon changing the first editable field ,press TAB to move to the next editable field . To come to the previous editable field use SHIFT + TAB. Press ENTER or ESC keys to cancel filed editing and retrun the code editor to normal .
Code Snippet Types :
Expansion : these snippets allows the code snippet to be inserted at the cursor.
SurroundsWith : These snippets allows the code snippet to be placed around a selected place of code .
Refactoring : These snippets are used during code refracting
Surround –with Code Snippets
Surround –with snippets surrounds the selected code, with the code snippets code.
1-Select the code to surround, and use keyboard shortcut CTRL K+S.
2-Select the code to surround , right click and select “Surround with..” option from the context menu. 3-Select the code to surround, then click on Edit menu, select “IntelliSense” and then Select the “Surround with “ command.
Code snippets can be used with any type of applications that you create with visual studio . For example , you can use them with .
Console applications.
ASP.NET web applications ASP.
NET MVC applications Etc..
Code snippets are available for the following languages
1. C#
2. Visual Basic
3. XML
4. HTML
5. Jscript
6. SQL
Code Snippet Manager
Code Snippet Manager can be used to add or remove code snippets .you can also find the following information about a code snippet.
1. Description.
2. Shortcut .
3. Snippet Type.
4. Author.
To access code snippet manager, click on “Tools” and then select “Code Snippet Manager”.code Snippets are Xml files and have .Snippet extension.
Tags:
C sharp