Re: constructors/default values

Bill Fellows <[email protected]> Thu, 11 Jan 2007 13:44:11 -0500
Newsgroups gmane.comp.windows.devel.dotnet.cx
Message-ID <LISTSERV%[email protected]>
True, I was thinking about a static variable - thanks for pointing that
out.

Bill

On Thu, 11 Jan 2007 17:23:05 +0100, Bart De Smet [MVP]
<[email protected]> wrote:

>Indeed, as I pointed out on my blog in the latest C# Quiz:
>
>http://community.bartdesmet.net/blogs/bart/archive/2007/01/03/C_2300_-
Quiz-_
>2D00_-Field-initialization.aspx
>http://community.bartdesmet.net/blogs/bart/archive/2007/01/04/C_2300_-
Quiz-_
>2D00_-Field-initialization-_2800_cont_2700_d_2900_.aspx
>http://community.bartdesmet.net/blogs/bart/archive/2007/01/08/Answers-to-
C_2
>300_-Quiz-_2D00_-Field-initialization.aspx
>
>The only caveat is the different order of field initialization which can
>yield different results as demonstrated in the latest post.
>
>-Bart
>
>-----Original Message-----
>From: Discussion relating to the specifics of the C# and Managed C++
>languages [mailto:[email protected]] On Behalf Of Richard
>Blewett
>Sent: donderdag 11 januari 2007 16:54
>To: [email protected]
>Subject: Re: [DOTNET-CX] constructors/default values
>
>I'm afraid this isn't accurate. This is only true if the variable is
static.
>There is no substantial difference between initializing a variable inline
>(known as a field initializer) and putting it in the constructor. If you
>look at the generated IL then the field initializer just becomes code in
the
>constructor anyway.
>
>The one difference is where in the constructor the code goes - the field
>initializers come first, then the call to the base class constructor then
>the actual constructor body
>
>Regards
>
>Richard Blewett - DeveopMentor

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

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