My Faq on "hashtable lookups for struct types" is published at


Check out 

for a FAQ on Hashtable lookup for value types.

My articles on "Anonymous types" is up

Check out for my article on “Anonymous Types“, This cool new feature coming in C# 3.0 is surely going to go places.

Codeguru also contains the same article at

Next stop, extension methods.

Guidelines on clean up code

Many a times, we use the catch block inside the try catch block for our clean up code.

Something like



 // Do something




    // work failed, clean up code here


Rather than the above approach of using the catch block, it would be nicer to use the finally block, something like


bool workSuccessful = false;



   // do some work

   workSuccessful = true;






    // cleanup code here.




There is elegance in the latter method and I would certainly recommend that approach, if you cannot use “using“. See below for details.


PS: Use this approach only if better alternatives are not available. One of the automatic cleanup approaches available with C# is the using construct.

Something like,

using (TextReader tr = new StreamReader(“FileName”))


  // do my work here.



The “using” construct automatically clean up the unmanaged resource (TextReader) once the block has completed execution.

In the event that you cannot use “using“, the try-finally approach would be the best way.


Visual Studio Service Pack WebSite

Visual Studio.NET Service Packs are due this year, but their site is up already (The site clearly mentions it is still in process)

  • Visual Studio 2003 Service Pack 1 ships Q2, 2006
  • Visual Studio 2005 Service Pack 1 ships Q3, 2006
  • Visual Studio 2005 – A Guided Tour

    Want to learn more about Visual Studio 2005.

    MSDN magazine folks have come  up with a new issue dedicated solely to the new IDE.

    Check it out online at


    Visual Studio Tip of the day – Bookmarks

    How often do you wish that you could put a mark at a particular location in your source code and then switch to that point with a simple click?

    With Visual Studio, you can do that with the help of bookmarks.

    A bookmark is a virtual placeholder which notes the position where you place one and you can quickly go to that position from anywhere in your source files by just a few keyboard clicks.

    How to define a bookmark?

    To create a bookmark, press Ctrl K + Ctrl K

    This creates a book mark in the code. This is indicated by a blue button like indication on the left side of the line where you placed the bookmark.

    Now to switch bookmark from any portion of your code, just press Ctrl K + Ctrl N

    To go to previous bookmark, press Ctrl K + Ctrl P

    To unmark a particular bookmark, navigate to that bookmark and press Ctrl K + Ctrl K (yes, this is the same combination you used to create a bookmark, what you are currently doing is toggling a bookmark)

    To clear all your bookmarks, press Ctrl K + Ctrl L

    If you have many files in your current folder and you want to navigate to the next bookmark in the folder, the shortcuts for next bookmark in folder is Ctrl Shift K + Ctrl Shift N and the previous bookmark in folder is Ctrl Shift K + Ctrl Shift P

    All the above options are also available from the menu, Edit > Bookmark > ….

    If you want to see all the bookmarks in one window, Go to View -> Bookmark Window (Ctrl K + Ctrl W). And click on the bookmark you want to go to.

    Happy coding.

    This post is aggregated at 

    RSS link:




    Incremental search – VS2005

    One of the lightly used features of VS2003 and VS2005 continue to be Incremental search. Developers usually know the text which they are searching for.

    Due to lack of awareness of the VS editor features, I have seen many a developers editing code in TextPad and other editors.

    If you know the exact text which you are searching for, you can use the incremental search feature of Visual Studio.

    Press Ctrl + I. and start typing the text you are looking for. Your cursor will start to look like binocular facing downloads, and the first text matching the pattern will be selected. As you keep typing the complete text, the selection will jump to the location with contains the complete text. The status bar will contain the text you are looking for.


    Hot keys:

    Start Incremental Search: Ctrl + I

    Made a mistake in typing: Hit Backspace till the wrong text is removed

    Found the text you were searching for: Hit Escape

    Change the search direction: Ctrl + Shift + I

    FYI: System.Web.Mail is deprecated use System.Net.Mail

    While we are on the topic of System.Web.Mail, it is important to note a new namespace in version 2.0 of the .NET Framework.  There is a brand new namespace for sending mail via managed code, it is called System.Net.Mail.  Have no fear, System.Web.Mail is still accessible in v2.0 but it is deprecated.  (Which means v2.0 won’t break your code but you should strongly consider using System.Net.Mail in new development.)  The documentation for System.Web.Mail is updated to reflect this.


    Absolute Beginner’s Video Series to Visual Studio 2005 Express Editions

    Do you have some students who want to learn Visual Basic .NET or C# on their own? Or perhaps you want to learn them as part of your own professional development. Well if so, Microsoft has a free series of lessons for absolute beginners. They look pretty good to me. I am sure that may others will find them useful as well.

    Visual Basic Express –

    Visual C# Express –

    WinFX November CTP Released!

    Download links


    Next Page »