Quiz: Initialising static fields correctly

Brad Adams has an interesting post on this blog, but before you go and read it, take a crack at it here and let me know what your answer is. There is an interesting thread going on there and I honestly cannot figure out the “bug” and being the impatient fool I am, I need to know the answer! 🙂

A dev on the team recently found a bug in Whidbey a long these lines…  Say you want to initialize the value of a static int to zero… which code should you use (C1 or C2) and, of course the most important point, why?

 

    class C1

    {

        private static int value = 0;

    }

 

    class C2

    {

        private static int value;

    }

 You can read it all on Adam’s blog.

Published by

Amit Bahree

This blog is my personal blog and while it does reflect my experiences in my professional life, this is just my thoughts. Most of the entries are technical though sometimes they can vary from the wacky to even political – however that is quite rare. Quite often, I have been asked what’s up with the “gibberish” and the funny title of the blog? Some people even going the extra step to say that, this is a virus that infected their system (ahem) well. [:D] It actually is quite simple, and if you have still not figured out then check out this link – whats in a name?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.