6 thoughts on “Assigning default values to variables trivia

  1. Should value assumed to be set as “false” by default ?
    or… Will be a warning generated because value is not assigned ?
    wait a minute… “value” is a reserved word used in get / set accessor:

    I would say “fail to compile”. going to try it right now ๐Ÿ˜€

  2. I agree with Mladen. value must always be initialized before used and that is not the case. BTW, value can’t be “null” because it is a value type. I’m sure Mladen just used “null” to describe “uninitialized”.

    LaurentB: I think “value” is reserved only in property setter. It can be used in normal methods.

  3. Hey guys,

    The answer is no, it won’t compile because value variable isn’t defined in all case and thus compiler will yield an error.

    And no, there is no problem in using “value” as a variable name outside settters (in fact I am using it often ๐Ÿ™‚ ).

Leave a Reply