MSDN Code Samples

One not-so-secret developer productivity technique is copying code. It's rare that I manually type in all of the required code for a program when it's faster and easier to grab bits of other projects that are already written, paste them into my new project, and modify them to get things working. Most .NET developers know that one of the best sources for code snippets is the Microsoft Developers Network (MSDN) on the Microsoft Web site ( Although some MSDN content—specifically downloadable products—is available only to MSDN subscribers, most of the site's code samples are free to all visitors. Here are some of the best places to find .NET code samples on the MSDN site.

4. 4MSDN Download and Code Center

The MSDN Download and Code Center ( includes links to all Microsoft downloads, including MSDN subscriber downloads and Microsoft Research downloads. One of my favorite SQL Server?related downloads is the AdventureWorks Cycles Store Front, a sample Web front-end for the Adventure-Works database.

3. Code Swap

Although theVisual Studio.NET CodeSwap site ( isn't technically part of MSDN, the MSDN site features links to this site. Microsoft code samples are always useful (and they usually work), but non-Microsoft developers can give you a different (and often more practical) approach to using .NET. Developers post their code samples to the site, and users who have installed the free CodeSwap add-in can download the samples and rate them.

2. Starter Kits

Fully functional projects in their own right, .NET starter kits ( .com/vs2005/downloads/starterkits/default .aspx) are basically project templates that you can download and use as a jumping-off point for building similar projects. Starter kits come in two sets: one for Windows Forms developers and another for Web developers.The Windows Forms starter kits contain a project for building shareware software products, including product-activation and PayPal ecommerce code, a Web-log analyzer, and a card game. The Web starter kits include a starter ASP.NETWeb site, a time-trackerWeb site, and a sample that shows how to create personalized Web content by using the ASP.NET 2.0 membership classes.

1. 101 Code Samples

One of the richest areas for mining reusable source code, MSDN's 101 code samples ( loads/101samples/default.aspx) are collections of Visual Studio 2005 code written inVisual Basic .NET and C#. Some of the code samples include data-access routines that show how to use asynchronous queries, create SQLCLR user-defined types (UDTs), read and write images to the database, use Multiple Active Result Sets (MARS), and more. Other code samples showWeb-development routines and Windows Forms development techniques. Visual Studio 2005 users really must have a bookmark for this page.

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.