Developer .NET UPDATE--Write Code Without Having to Type It--April 21, 2006

This Issue Sponsored By
This email newsletter comes to you free and is supported by the following advertisers, who offer products and services that might interest you. Please take a moment to visit these advertisers' Web sites and show your support for Scripting Central.

Double-Take Software


1. Developer .NET Perspectives

  • Write Code Without Having to Type It
  • 2. Events and Resources

  • Guide to SQL Server 2005 High Availability
  • Exploit the Opportunities of a Wireless Fleet
  • Are You a SQL Server Superhero?
  • Become a Master of Messaging
  • 3. Featured White Paper

  • Secure Your Online Data Transfer with SSL
  • 4. Announcements

  • Exclusive Spring Savings
  • Save 44% off the Windows IT Security Newsletter

  • Sponsor: Double-Take Software

    Start your disaster recovery program before it's too late - including defining the right plan for you, and mistakes to avoid when planning

    1. Developer .NET Perspectives

    by Bill Sheldon, [email protected]

    Write Code Without Having to Type It
    A lot of the code that developers write follows common patterns. For example, when you create a new property, you follow four steps:

    1. Declare a private variable.
    2. Declare the public property with a public name of the same type.
    3. Declare the Set logic, which sets the private variable to the parameter value.
    4. Declare the Get logic, which returns the private variable's value.

    These four steps are common to every property you want to place in a class. Manually typing all that information is not only repetitive but also time consuming and error prone (mainly typing errors).

    Visual Studio 2005 lets you avoid all that hassle. Its new code snippet feature lets you include code without typing it. For example, to include code that creates a property, you simply type "prop" if you're using Visual C# or "property" if you're using Visual Basic (VB) 2005, then press the Tab key. In your source code, you'll find a template that includes all the generic code you would normally type. The sections that you need to edit in your new property declaration (e.g., variable name, property name, type) are all highlighted. After you edit the contents of a highlighted section, you press the Tab key to go to the next section. The changes are reflected across the entire declaration for consistency. This constitutes an important difference between using this feature and uploading stock code. With this feature, you're literally pulling in a code template with active tags that specify the initial customizable properties in that template.

    Most all the keywords in VB 2005 or Visual C# have been associated with a code snippet. Can't remember the exact syntax of the For loop? No worries. Type "For", press the Tab key, and--poof--the necessary code appears. Can't remember the keyword you need to use? No problem. Right-click somewhere in your edit window and select Insert Snippet. Visual Studio 2005 first inserts a placeholder in the location where you want to include a snippet, then provides a list of snippet categories in the Code Snippet Picker.

    Visual Studio 2005's code snippet feature goes well beyond just providing templates for common language elements. Templates are also provided for common tasks, such as pinging a remote computer or connecting to a database. In addition, a template contains more than just source code. The template also includes additional information, such as the snippet's author, the namespaces that need to be imported (if applicable), a display title, keywords the user needs to edit, and which keyword should be edited first. For general information about code snippets, you can check out the Visual C# help files at

    The good news is that Visual Studio 2005 shipped with hundreds of code snippets. The bad news is that the snippets are, as you might expect, language specific and therefore not interchangeable. For example, some of the VB 2005 snippets leverage the "My" namespace, which doesn't exist in Visual C#.

    The code snippets have their own schema, which is documented at As a result, you can create your own custom snippets. Step by step instructions for doing so are available at

    Snippet files are XML files. So, to create snippets, you must edit an XML file, which isn't much fun. Fortunately, if you use VB 2005, there's a GUI called the Visual Basic Snippet Editor that you can use. This free editor is currently in the release candidate (RC) stage. For more information, visit the Microsoft Developer Network (MSDN) Web page at Or for the most recent version, bypass MSDN and look in the GotDotNet Workspace at

    Sponsor: Macrovision

    Strategically manage your organization's software licenses with a 5-step program to help save time and cut costs by centralizing licensing operations.

    2. Events and Resources

    (brought to you by SQL Server Magazine)

    Guide to SQL Server 2005 High Availability
    Learn the essentials of high availability for SQL Server 2005--including cluster services, replication, and log shipping.

    Exploit the Opportunities of a Wireless Fleet
    Industry guru Randy Franklin Smith helps you identify what you should do to leverage your mobile and wireless infrastructure, how to pick devices that are right for you, and more!

    Are You a SQL Server Superhero?
    Gain control of your messaging data with step-by-step instructions for complying with the law, ensuring your systems are working properly, and ultimately making your job easier.

    Become a Master of Messaging
    Gain control of your messaging data with step-by-step instructions for complying with the law, ensuring your systems are working properly, and ultimately making your job easier.

    3. Featured White Paper

    Secure Your Online Data Transfer with SSL
    Increase your customers' confidence and your business by securely collecting sensitive information online. In this free white paper, you'll learn about the various applications of SSL certificates and how to deploy them appropriately, along with details of how to test SSL on your Web server.

    2006 Watch

    Learn C# 2005 Now...Get a FREE training CD!
    Start learning Visual C# 2005 today with cutting edge training from AppDev. We'll send you a C# 2005 training CD from our new course (a $115 value) -- FREE! Start learning the link below for your FREE Visual C# 2005 training.

    4. Announcements

    (brought to you by SQL Server Magazine)

    Exclusive Spring Savings
    Subscribe to Windows IT Pro and SAVE 58%! Along with your 12 issues, you'll get FREE access to the entireWindows IT Pro online article archive, which houses more than 9,000 helpful articles. This is a limited-time offer, so order now:

    Save 44% off the Windows IT Security Newsletter
    For a limited time, order the Windows IT Security newsletter and SAVE up to $80! You'll get 12 helpful issues loaded with endless fundamentals on building and maintaining a secure enterprise, in-depth product coverage of the best security tools available, and expert advice on the best way to implement various security components. Subscribe now:

    Hot Spot

    Find solutions to manage multiple regulations effectively, saving time and expense when demonstrating compliance.

    Contact Us

  • About Developer .NET Perspectives -- [email protected]
  • About technical questions --
  • About product news -- [email protected]
  • About your subscription -- [email protected]
  • About sponsoring an UPDATE -- contact Richard Resnick, [email protected], or Lisa Kling, [email protected]
  • Developer .NET UPDATE is brought to you by SQL Server Magazine, the only magazine devoted to helping developers and DBAs master new and emerging SQL Server technologies and issues. Subscribe today.

    You can manage your SQL Server Magazine email newsletter subscriptions by going to

    You can view the SQL Server Magazine Privacy Policy at

    SQL Server Magazine is a division of Penton Media, Inc. 221 East 29th Street, Loveland, CO 80538, Attention: Customer Service Department

    Copyright 2006, Penton Media, Inc. All Rights Reserved.

    Hide comments


    • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

    Plain text

    • No HTML tags allowed.
    • Web page addresses and e-mail addresses turn into links automatically.
    • Lines and paragraphs break automatically.