Presentation is loading. Please wait.

Presentation is loading. Please wait.

Doing Snippets in.NET Tuc Goodwin February 2008. Agenda What is a “snippet”? Where do I find Snippets? How do I use snippets? Demo How do I create a snippet?

Similar presentations


Presentation on theme: "Doing Snippets in.NET Tuc Goodwin February 2008. Agenda What is a “snippet”? Where do I find Snippets? How do I use snippets? Demo How do I create a snippet?"— Presentation transcript:

1 Doing Snippets in.NET Tuc Goodwin February 2008

2 Agenda What is a “snippet”? Where do I find Snippets? How do I use snippets? Demo How do I create a snippet? What is the XML format for a snippet? Other Examples Other Tools Other Resources Review

3 What is a “snippet”? Visual Studio 2005 includes a code library consisting of several hundred pieces of code, called IntelliSense code snippets, that are ready to be inserted in your application. Each snippet performs a complete programming task such as creating a custom exception, sending an e-mail message, or drawing a circle. You can insert a snippet into your source code with a few mouse clicks.

4 What programming Languages do I have snippets in? C# VB.Net XML J#

5 Where do I find Snippets? On your Machine  C:\Program Files\Microsoft Visual Studio 8\VB\Snippets\1033  C:\Program Files\Microsoft Visual Studio 8\VC#\Snippets\1033 On the Internet  http://www.gotcodesnippets.net/default.aspx http://www.gotcodesnippets.net/default.aspx

6 How do I use snippets? While you are writing code… There are two ways that you can easily use snippets:  Snippet Manager  Control keys

7 Snippet manager To access the Code Snippets Manager On the Tools menu, click Code Snippets Manager

8 Control Keys To access the Control Keys From the Edit menu, choose IntelliSense, Insert Snippet or Ctrl K, Ctrl X

9 Demo Create a Snippet Dim strReply as String strReply = InputBox("Please enter the passcode", _ "Secret PassCode") If strReply.ToUpper.Equals("$strSecret$".ToUpper) Then MsgBox("Welcome!", MsgBoxStyle.Information, _ "$strTitle$") Else MsgBox("Access Denied!", MsgBoxStyle.Critical, _ "$strTitle$") End If

10 Ok, how do I create snippets? title author shortcut description SurroundsWith Expansion name value $name$ $selected$ $end$ ]]>

11 OR Insert an XML File Use the Snippet Manager / Control Keys Secret: Got to add …

12 Snippet manager The Code Snippets Manager allows you to set the directories and individual snippets that you want available to insert into your code.

13 To import a code snippet into the Code Snippet Manager 1. In the Language list, select the language that you want to add the code snippet. 2. Select the existing folder that you want to place the imported code snippet into. 3. Click Import. This opens the Code Snippets Directory window. 4. Select the code snippet file that you want to add to the Code Snippets Manager and click OK. 5. The code snippet is now available for insertion into the code editor.

14 Other Tools

15 Review We used code snippets We created code snippets We imported code snippets

16 Next Time MarchWhat’s New in VS 2008 AprilADO.NET Revisited MayXML Serialization JuneTBD


Download ppt "Doing Snippets in.NET Tuc Goodwin February 2008. Agenda What is a “snippet”? Where do I find Snippets? How do I use snippets? Demo How do I create a snippet?"

Similar presentations


Ads by Google