Re: constructors/default values

Peter Ritchie <[email protected]> Tue, 2 Jan 2007 11:33:12 -0500
Newsgroups gmane.comp.windows.devel.dotnet.cx
Message-ID <LISTSERV%[email protected]>
If I remember correctly, assigning values to class value members is
a "shorthand" for doing it in the constructor.  It's slightly different
and is more performant to do it in the member declaration because the CLR
normally initializes value types to their default value (usually zero)
BEFORE the constructor.  If you put the "initialization" of your value
members in your constructor I believe you get two assignments instead of
one.  I'd have to double check that, the compiler may be smart enough to
optimize that out...  There is at least one FxCop rule related to that
that suggests it doesn't get optimized out (CA1805).

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com