It has been six months since I joined microsoft. I have moved this blog to a new location. http://blogs.msdn.com/vipul
Please update your bookmarks to the new URL. Link to RSS feed : http://blogs.msdn.com/vipul/rss.xml
for a FAQ on Hashtable lookup for value types.
EricGu (Microsoft) has made an excellant post on readonly strings and read-only properties. Check it out
Check out http://www.developer.com/net/csharp/article.php/3589916 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 http://www.codeguru.com/csharp/csharp/cs_misc/designtechniques/article.php/c11551/
Next stop, extension methods.
Many a times, we use the catch block inside the try catch block for our clean up code.
// 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.
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.
A static constructor is invoked by the first of either of the following conditions:
Confused ? Read ahead…
Console.WriteLine(“Static method called”);
In the above example, call to the static method WriteTime first calls the static contructor of the class Sample and then the static method is called.
In your Console.Window , you will see:
Line1: static constructor called
Line2: Static method called
If after this, you create an instance of the class, the static contructor is not called, as it is only invoked once per class at its first reference (mentioned above). So, call 2
Sample aNewSample = new Sample(); // call 2
will not invoke the static constructor.
On the other hand, if there was no call 1 (call 1 is commented out), the static contructor will be invoked when the first object of Sample class is created (a little before the object is created).
Check out http://blogs.msdn.com/psheill/archive/2006/02/20/535614.aspx for a fantastic quiz on SQL Server 2005 blocking and verify if you have got your fundamentals right.
Good job, psheill.
Office Live (still in beta) website http://officelive.microsoft.com/ went live today.
So what does Office live have for me?
Three categories of services:
1. Microsoft Office Live Basic: Easy to use web site design tool (ala Frontpage online), Free domain name and hosting , 5 personalized email accounts(Office live mail), good data storage and data transfer facilities, and best of all web site traffic analysis and reporting tools, with online support. And all this for free, till the beta period.
Web hosting details:
2. Microsoft Office Live Collaboration: Shared sites(remember Sharepoint), on demand company applications (like shared calenders, Employee directory, expenses, jobs, hiring, Customer management, sales and marketing), and 50 MB of disk space, backed by enhanced data protection.
3. Microsoft Office Live Essentials: Microsoft Office Live Basic + Sharepoint + 50 email accounts + Microsoft project.. — Complete tools to manage your business online… One stop solution for all your needs. (Free domain name and hosting, Easy to use web site design tool (ala Frontpage online).
So lets get started.
Do you want your application not in appear in Add/Remove Programs list?
If yes, ARPSYSTEMCOMPONENT property of the Windows Installer SDK helps.
Setting this property to 1 prevents the installed application to be displayed in the Add/Remove Programs List.
More information on this key is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/arpsystemcomponent.asp
On a side note, i fyou want a quick access to Add/Remove Programs List, type appwiz.cpl at your Start > Run prompt.
Visual Studio.NET Service Packs are due this year, but their site is up already (The site clearly mentions it is still in process)