How to Use Code Snippets in the Visual Studio 2010 IDE

Code Snippets allow you to automatically insert short fragments of code into your program. Based on Code Templates that you can create and edit yourself, Code Snippets are easily customizable. This video shows how Code Snippets work, how to edit existing Code Snippets and how to create your own Code Snippets. This feature requires Visual Studio 2005 or higher.


Microsoft Ajax Minifier

One good thing I came across at the Microsoft MVP Summit is that Microsoft released Ajax Minifier, a tool to compress the size of Javascript (.JS) and Cascading Style Sheets (.CSS) files. Later I found a Scott Gu post on it.

The Microsoft Ajax Minifier is a small tool to remove unnecessary content from your js or css file. It can bring down the size of js file by 60%. You can download the Ajax Minifier from here.

After installing the tool, you will get a command prompt


and let’s say I have a js file with name “Validations.js” Let’s try minifying the file using this tool

A point to note here is:
Original Size: 7710 bytes; reduced size: 4918 bytes (36.2% minification)
Gzip of output approximately 1586 bytes (67.8% compression)

Currently the Ajax Minifier ships with two modes of

  1. Normal Crunching
  2. Hyper Crunching

With normal mode, it removes extra whitespace, all comments etc. When you use Hyper crunching mode it takes some more additional steps that includes shorting the name of local variables etc.

In order to use hyper crunching mode you need to add –hc switch in the command line. For instance:

ajaxmin validations.js –hc –o validations.min.js

So go ahead and try it out. Another great thing is that Ajax Minifier can be integrated with Visual Studio as well, which I will cover in the next post.

Visual Studio 2010 RC is now available

8th Feb, 2010  Microsoft released release candidate (RC) of Visual Studio 2010. The VS 2010 RC will be available to download for general public on 10th Feb 2010. Earlier we saw some glimpse of Visual Studio 2010 beta 2 as well as some Intellisense improvement. So if you are like me who installed beta 2 of VS2010 and downloaded RC, you might need to read this post.

Note that there is no direct support of Beta 2 to RC upgrade. You need to uninstall the Visual Studio 2010 Beta 2 as well as .NET Beta 2 and then install VS2010 RC. The snapshots below might help you identify the items to uninstall.

Uninstalling VS 2010 Beta 2 Uninstall dotnet4 beta2

We already saw plenty of features that were introduced in Beta 2. As per Microsoft in RC there are major performance improvements in Visual Studio 2010. Also note that the RC includes a go-live license for people who want to deploy in their production environment. If you haven’t tried VS2010 yet, I would recommend you to download Visual Studio 2010 RC and you will love it. You can run Visual Studio 2010 RC along with Visual Studio 2008 SP1. The RTM is expected in April 2010.

If you are facing any bandwidth issue and you are in Karachi – Pakistan, feel free to contact me and I will try to burn a DVD for you or copy ISO file (around 2.4 GB) on your USB.

Till the RTM, Happy exploring Visual Studio 2010 RC.

Session Summary: .NET Overview and Visual Studio

I recently participated as speaker at “MAJU TechCon 2009” held on Saturday, 21st November, 2009. I delivered a session on “.NET Framework and Visual Studio”. The event was day long and targets mostly to students of undergrad and post-grad.

Adil at MAJU TechCon 09

The objective of the session was to introduce .NET Framework as a next generation Microsoft platform for building end-to-end applications and why students should learn to program using .NET Framework. Following was the agenda of the session (slide copied):


At the end, we discussed the upcoming .NET 4.0 and Visual Studio 2010, in particular, how .NET 4 address the multi core systems and a little on Dynamic Language Runtime (DLR). I also demonstrated small samples on using Parallel APIs in .NET 4.0 Beta.

In the end, I would like to thank everyone who attended the session. The slides and demo are available on my Box .net folder available, refer to sidebar on right hand side on my blog in folder “MAJU TechCon”.

Please click here to see my earlier post for information about event schedule and program details.

Intellisense Improvements in Visual Studio 2010

This is another post on the 10-4 series. I showed some screen shots of the Visual Studio 2010 beta 2 in the last post and promised that we will be discussing some of the breaking changes in the upcoming Visual Studio 2010. So, in this post we are going to see some of the exciting, very handy change and good improvement in Intellisense.

A major thing you will notice that Intellisense now supports search by Keywords i.e. the Intellisense will filter no matter you type characters that are either in start or in between or at the end of any member. Let’s look at the screenshot below:


You can notice that I just type ‘Co’ and it brings out all the members containing Co such as BackgroundColor, ResetColor, TreatControlCAsInput etc. So it will be pretty handful for the programmers as they don’t have to recognize the exact starting characters to filter results.

Another good point you might have noticed is that earlier Intellisense use to apply filter in a drop down where as now Intellisense only display the members with a particular keyword rather than a drop down.

The last major change is something related to Pascal casing. Now most of us follow Pascal casing for our methods, properties and class name. So the Intellisense now supports Pascal Case filtering. For instance, I want to search a method CompareTo and I can simple search that by writing CT (based on the pascal case) so the Intellisense will recognize it and will display the filtered result as shown in the code below:

Those were some of the pretty cool features in Visual Studio 2010 Intellisense that will help programmers in finding classes and other members. I hope you like them. Until next post, have a great time!

A glimpse on Visual Studio 2010 Beta 2

Great News! Microsoft recently shipped Visual Studio 2010 Beta 2 and is available to download for general public on October 21st.

The very first thing you will notice is the new logo

  VS LOGO MOdified 

Another change you will observe is that Visual Studio now comes with four edition:

  • Visual Studio Express
  • Visual Studio 2010 Professional with MSDN
  • Visual Studio 2010 Premium with MSDN
  • Visual Studio 2010 Ultimate with MSDN

For details about these SKUs, visit Scott Gu post here. Due to MSDN Subscription, I have downloaded Visual Studio 2010 Beta 2. So let’s go ahead and see some of the screen shots of installation.

Setup Screen 1 Setup Screen 2 Setup Screen 3 Setup Screen 4 Setup Screen 5

and it will take some time to complete installation 🙂 So Let’s move ahead. Here is the new splash screen


Now there are number of changes in the start up page and it seems to be better organized.

VS 2010 Beta 2 Start Page

And of course the support of targeting different framework versions.

Start New Project

There are numerous new and exciting features that are going to released along with Visual Studio 2010 Beta 2 that we are going to see in several posts ahead.

C# 4.0 + Visual Studio 2010 Beta + Windows 7 RC

Here we are with the Visual Studio 2010 Beta installed on Windows 7 RC, the most coolest and latest stuff out yet 🙂

In this post, I wanted to share some glimpse at Visual Studio 2010 beta along with some demonstration of one of the feature of C# 4.0 🙂 For Windows 7, I will write another detail post about the new features and what I like most and why it can be the best windows till yet!

So, coming back to VS 2010, If you start Visual Studio 2010 Beta, you will notice a major change in UI of Visual Studio with a nice, interactive and customizable startup page :

VS 2010 Beta Start up

Yes, It’s UI is built on Windows Presentation Foundation (WPF). So let’s go ahead and create a new project:

As you can see we have a similar kind of option, as in VS 2008, is available to select target framework version which is by default 4.0 🙂 and as you can see we have Silverlight templates available so now no need to install separate Silverlight 2 tools for VS :). Let’s move forward and create a new C# Console Application:

You will notice that editor itself is in WPF along with the intellisense menu but works almost as identical. So let’s try one of the feature of C# 4.0 🙂

I’m going to implement a method that takes dynamic typed object and that object will invoke a method which will be resolved at runtime!


Didn’t get? Keep reading 🙂 Here we have a DemoCSharpFeature class that have a static method having a dynamic parameter “obj”. Now inside that method, I have written obj.ABC() which can be resolved only at runtime because at compile time, compiler does not know what will be the actual type and it will be resolved dynamically at runtime and hence compiler will not raise a compile time error here 🙂

I have created another DemoClass which have method ABC.

Main Method 

As you have noticed that I have created an object of DemoClass which contains method “ABC” and passed to CheckDynamicParameter. The demoObj parameter will be resolved at runtime and it will find ABC method in it. Thanks to dynamic type in C# 4.0, otherwise I would have used Reflection here or static typed object 🙂

Let’s hit F5!


The beauty is that even if I remove method ABC from DemoClass, the program will still compile because it will expect that when dynamic is resolved at runtime it will find the method ABC and if not found, a Runtime Binder Exception would raised.

That’s all for today! If you want to download Visual Studio 2010 Beta, visit Visual Studio on MSDN

.NET Day

Adil Last weekend I participated as speaker in “.NET Day” – A full day free event for students, organized by DevNext and IEEE-CS (FAST-NU) at FAST- National University of Computing and Emerging Sciences, Karachi, Pakistan.

I’m very glad to see the interest of students and their feedback. I talked on “Visual Studio 2008 Tips and Tricks” and more specifically Visual C# IDE. Visual Studio is one of the most powerful IDE and developers usually don’t know the features available that can really enhance their productivity.

Following were the areas discussed:

  • Code Navigation
  • Refactoring
  • Code Snippets
  • Debugging Techniques
  • Visual Studio SDK

Shield In the end, I got thank you shield from IEEE-CS, FAST-NU 🙂 I would like to thank every one who attended my session and also to IEEE-CS for working in collaboration with DevNext.

For details about the event, please visit “DevNext – .NET Day Event Summary

C# 4.0

After watching the Anders Hejlsberg’s session “The Future of C#” on Channel 9, I’ve got excited to get hands on the upcoming features of C#. Since the inception of C#, each version bought some major changes and amendments in the language. Like, In C# 1.0 the major theme was Managed Code then in C# 2.0, Generics were introduced and lastly in C# 3.0 LINQ was introduced. C# 4.0 introduced the concept of Dynamic Programming in C#. Overall there are four main features that are introduced in upcoming C# 4.0:

  1. Dynamic Typed Objects
  2. Optional and Named Parameters
  3. Improved COM Interoperability
  4. Co- and Contra-Variance

We will explore these features one by one in the upcoming posts. A document related to New Features in C# is available at MSDN that explain all of the above features in a little detail. Plus if you are interested in getting an early look on Visual Studio 2010 CTP, you can follow my post on Visual Studio 2010 CTP.

Have a good time!

Visual Studio 2010 CTP


In order to try out fantastic features in the upcoming C# 4.0, today I downloaded Microsoft Visual Studio 2010 and .NET Framework 4.0 Community Technology Preview (CTP). Microsoft is currently providing Virtual Machine(VM) hard disk to be run on Microsoft Virtual PC SP1. The first look of VS 2010 shows you a new good looking start page built on WPF, which can be customized as well 🙂

There are plenty of features coming in C# 4.0 which we will discuss in the coming posts. For now, If you are interested in getting first look of the upcoming technology you can download it from Visual Studio 2010 CTP Feedback Home. The download size is very large, around 7 GB, make sure you use some download utility for that. There are plenty of tips and suggestions are posted for downloading and using CTP but here I will recommend you to visit following links before using CTP:

Also there is also a video available on Channel 9 which will help you in working with the Visual Studio 2010 CTP.