T
twawsico
I ran into this while converting some DX C# code to VB.NET (VS 2003),
and I'm just curious as to whether this is intended behavior (and if
so, where might I read up on it) or more of a bug.
This involves creating a New instance of a derived class that inherits
a base class. In C#, private member vars in the derived class ( e.g.
private MySimpleObject MyObject = new MySimpleObject()
are
instantiated immediately when the the calling code attempts to
instantiate the derived class. Order of execution then goes
DerivedClass::New() method, then (before executing code within
DerivedClass::New) to BaseClass:New().
The problem/difference is that, using the same classes in VB.NET, the
order of execution changes. The private member var object in the
Derived class does not get instantiated until AFTER the execution
returns from BaseClass.New() and begins the actual code within
DerivedClass.New().
I can implement a workaround (this actually causes errors with the DX
code due to an overridden method which expects the object to have been
instantiated by that point). But is this an *intended* difference
between the two languages?
If my explanation of the problem isn't clear, please advise and I'll
post some sample code. It's easy to reproduce.
Thanks in advance.
and I'm just curious as to whether this is intended behavior (and if
so, where might I read up on it) or more of a bug.
This involves creating a New instance of a derived class that inherits
a base class. In C#, private member vars in the derived class ( e.g.
private MySimpleObject MyObject = new MySimpleObject()

instantiated immediately when the the calling code attempts to
instantiate the derived class. Order of execution then goes
DerivedClass::New() method, then (before executing code within
DerivedClass::New) to BaseClass:New().
The problem/difference is that, using the same classes in VB.NET, the
order of execution changes. The private member var object in the
Derived class does not get instantiated until AFTER the execution
returns from BaseClass.New() and begins the actual code within
DerivedClass.New().
I can implement a workaround (this actually causes errors with the DX
code due to an overridden method which expects the object to have been
instantiated by that point). But is this an *intended* difference
between the two languages?
If my explanation of the problem isn't clear, please advise and I'll
post some sample code. It's easy to reproduce.
Thanks in advance.