Code Snippets in Visual Studio 2005
page 4 of 7
by Bilal Haidar
Average Rating: 
Views (Total / Last 10 Days): 35085/ 120

A Code Snippet

In this section, I will demonstrate on a ready-made code snippet that ships with Visual Studio 2005.

Listing 1 below shows the property code snippet that ships with Visual Studio 2005.

<?xml version="1.0" encoding="utf-8" ?>

<CodeSnippets xmlns="">

  <CodeSnippet Format="1.0.0">




      <Description>Code snippet for property and backing field</Description>

      <Author>Microsoft Corporation</Author>









          <ToolTip>Property type</ToolTip>





          <ToolTip>Property name</ToolTip>





          <ToolTip>The variable backing this property</ToolTip>




      <Code Language="csharp">

<![CDATA[private $type$ $field$;

public $type$ $property$


  get { return $field$;}

  set { $field$ = value;}







In the Header section, you can see the informative information about the code snippet including a title, a shortcut, a description, an author, and snippet types.

The Snippet section includes two sections, the Declarations and the Code section.

As mentioned above, the Declarations section contains definitions for the replicable values inside the code snippet. In this example, the prop code snippet should define three replicable values, the private field name, the property name, and finally the property data type.

The mandatory code section includes the usual code for a property. You can see the replicable values surrounded by the $ sign. Those values have been defined above in the Declarations section. It is the developer using the code snippet who would replace those values with proper values.

View Entire Article

User Comments

Title: developer   
Name: sunil
Date: 2009-10-27 9:23:04 AM
very nice exmpl
Title: developer   
Name: nanda
Date: 2007-08-06 2:00:31 AM
nice article..
Title: Developer   
Name: Stefan Leoni
Date: 2006-12-13 7:18:51 AM
concise. Excactly what i was looking for.

Title: Re:   
Name: Bilal Haidar
Date: 2006-01-20 3:38:15 PM
You can now, discuss, comment, and ask me questions related to this article at this forum:

Title: Solution Developer   
Name: Mostafa
Date: 2006-01-07 3:05:53 AM
Good Article.

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2024  |  Page Processed at 2024-05-28 9:56:34 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search