I know the answer (it's 42)

A blog on coding, .NET, .NET Compact Framework and life in general....

January, 2007

  • I know the answer (it's 42)

    More peculiarites of enum


    The well known (or moderately known fact): C# enums can contain any value supported by its base type and not just the ones specified in the enum. Lets consider the following enum.

    enum WeekDay
        Monday = 1,
        Tuesday = 2,
        Wednesday = 3,
        Thursday = 4,
        Friday = 5,
        Saturday = 6,
        Sunday = 7

    Even though the enum supports values from 1 to 7 you can do the following.

    WeekDay day = (WeekDay)40;

    This prints out 40 without any error.

    Now comes the lesser known fact: C# 1.2 spec sez "An Implicit enumeration conversion permits the decimal-integer-literal 0 to be converted to enum-type". This means the following is valid code

    WeekDay day = 0;

    Note that even though 0 is not supported it is implicitely casted to the enum!!! No idea why this is supported.

  • I know the answer (it's 42)

    Microsoft owns FireFox and Mozilla owns IE 7.0


    http://ie7.com is owned by a Firefox fan and advertises FireFox, recently I found out http://www.msfirefox.com/ which talks about Microsoft FireFox 2007 :) and it has a Microsoft copyright notice at the bottom.

     Ok  I'm super confused now!! Looks like IE 7 is a browser from Mozilla and FireFox is from Microsoft. Hope I got this right :|.

  • I know the answer (it's 42)

    Migrated from Windows 3.1


    Otherwise why do I have the registry key HKEY_CURRENT_USER\Windows 3.1 Migration Status on my Clean XP SP2 box?? I later found that others  have also found this earlier and were equally puzzled.

    Check any XP machine and you'll see this key. The burden of backward compatibility on Microsoft products is often too great :).  Interesting to note that my Vista box doesn't have it. So I guess Windows 3.1 can finally RIP.

    I found it as I was moving through the registry using PowerShell. Manipulating the registry has become extremely simple using PowerShell. You can move into the registry using something like cd HKCU: and then do a dir to see all the keys!! To find the above key try the following sequence.

    C:\>cd HKCU:
    HKCU:\>dir | select-string "3.1"
  • I know the answer (it's 42)

    The all new Yahoo messenger


    WPF is slowly catching up and revolutionizing the way we design and create UI. Check out the new Yahoo Messenger for Vista being developed with WPF at http://messenger.yahoo.com/windowsvista.php

  • I know the answer (it's 42)

    Happy New Year


    The worst part about new years is that you need to remember to write the new year in all dates you enter. Last time my credit card payment bounced because I entered 2005 on the cheque instead of 2006 and I had to pay late payment charges :(

    Ok, now since I'm over my crib session Happy New Year to everyone...

  • I know the answer (it's 42)

    More about new year


    It's a common custom to douse lights at 12:00 as the year changes. The funny part is that in Hyderabad the state owned electricity company actually shut off power at that time!!!!

    This is no coincidence as they did it last year too (that's when I had thought that it was coincidence). I guess there is some fun-loving official in that company whose sense of humour needs to be fixed....

  • I know the answer (it's 42)

    Y2K7 Problem Silently Went by


    Fortunately it hit only a very small set of people and was much less scary than the Y2K problem and we figured out in advance that flights need not be gounded nor schools closed down.

    Y2K7 was to do with how assembly versions are stored. The file versions are stored as two 32-bit integers defined by four 16-bit integers. So the version number is of the form A.B.C.D. Visual Studio 8.0 used the numbering scheme 8.0.YMMDD.NN. Where the YMMDD is the day the build is churned out and NN is the increment counter. Visual Studio 8 finally shipped as 8.0.50727.42.

    We have build labs that churn out builds every day and the one to be produced on 1th Jan this year was 8.0.70101.00. The problem is that the largest number that can fit into a 16-bit int is 65535 (0xFFFF) and hence the above number couldn't be produced and the build failed. Nothing much happened other than we changed the numbering scheme to not include the year prefix.

Page 1 of 1 (7 items)