codymanix said:
Indeed, although I've been arguing about this with someone else in
another place. Seems very odd to me.
Why? Providing a static ctor means you will have no beforefieldinit set in
the class which means that on first
access of any field, *all* static fields are initialized. But what if I
require lazy initialisation?
In fact, having a static constructor will probably end up giving you
lazier access - from what I've seen, the current CLR is likely to call
the type initializer when it first enters a method which uses any part
of the class.
Note that the idea of different static fields being initialized at
different times just isn't going to happen - there's only one type
initializer per type. (You could manually do it, of course, but that's
a different level from the type initialization one.)
ctor
He must be gone crazy. Some other people say you _always_ have to use this.
Indeed. I'm lazier - I say "Use this when you have to" and I use
variable names which mean that on constructors I usually have to.
Elsewhere I rarely end up using "this" - although there are times when
you want to use it for entirely different reasons, of course.
After reading this sosaid coding standard I created one rules for writers of
coding standards:
1.1.1
Never declare your personal preferences as official standard if over 50% of
other experts have another opinion.
Of course, it's very difficult to gauge that "50% of other experts".
Writing a "personal standard" seems to be a better bet, really. Maybe I
should have a go at doing that some time...