J
Jon Skeet [C# MVP]
John Wood said:I guess I wasn't being clear enough, sorry about that.
Thinking about it further, my opinion is that it actually makes sense to
explicitly initialize *all* value type variables, whether local or member
level. I like everything to be explicit, and I think this is more consistent
with the C# philosophy (where casting is also explicit, for example). For
member level, initialization could occur as part of the declaration, or in
the constructor(s).
I think the default null value for reference types makes sense and should be
implicit.
Do you disagree with that?
Yes - if reference type default values are going to be implicit, why
shouldn't value type default values? That particularly applies if
you're arguing for consistency!
If you want everything to be explicit, there's nothing to *stop* you
from assigning to members when you declare them - but I don't see why
it should be enforced. It's not like they have undefined values
otherwise or anything nasty like that.