Boni <oilia@nospam> wrote:
> the reason of my question is a problem in my "real" application. But I can't
> reproduce it in small examples.
How far have you got with taking the "problem" version and removing a
bit at a time?
> May be you have any ideas why this happens.
> In my understanding if I initialize member like this:
> private SomeClass _member = new SomeClass();
> than compiler will move this initialization into all constructors. (And it
> is what compiler does on small examples).
Yes - it's not quite as if it moves it into the first line of code in
your constructor; it calls the member initializers first, then calls
the base class constructor, then calls any code you've specified in
your constructor.
Does your base class constructors call any virtual methods which are
overridden in the derived class?
> But in "real" applicaton, compiler moves the initialization into one
> constructor only (I think default constructor). And if I create an object
> with other constructors, then _member is null.
> Can somebody help me to figure out, what the reason is?
I suspect you're not seeing what I think you're seeing. Have you tried
putting a breakpoint on it?
Unfortunately it's very hard to work out what's wrong without a test
case.
--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too