Saturday, 13 May 2006

Visual Studio Snippets

I was playing around with Visual Studio 2005 today and I found a neat little facility they have included called ‘Snippets’. Basically a Snippet is piece of pre-defined source code that does a very specific job. So, if for example you wish to send an email from within your VB.NET source code, and cannot remember the syntax, you can right click, select Snippet and you see options similar to the following:

Collections and Arrays
Common Code Panels
Connectivity and Networking

Selecting the ‘Connectivity and Networking’ Option will give you options similar to these:

Determine if the Network is Available
Create an E-Mail
Download a File Using HTTP

Selecting the ‘Create an E-Mail’ Option puts the following text within your source code:

Dim message As New MailMessage("sender@address", "from@address", "Subject", "Message Text")
Dim emailClient As New SmtpClient("Email Server Name")

Thats It ! All you need to do now is alter the arguments with your own specific values and call the procedure when necessary.

I like Snippets, its a good, simple, fast, high productivity enhancement to the Visual Studio development environment. Cool !

“I guess one person can make a difference. But most of the time, they probably shouldn’t.” - Marge Simpson

No comments: