boxedObject.GetType() returns the type of the box, not the type of the object

cjard

Well-known member
Joined
Apr 25, 2006
Messages
7,081
Programming Experience
10+
As per the subject line.. I am boxing an object:


Dim x as Parent = New Child


In the constructor of parent, I log an entry:

log.Write("A new " & Me.GetType() & " was created")



-

Problem is, this always writes "A new parent was created".. I need to know which child was created, so what else can i use in place of GetType() to return the type of the object, not the type of the box?
 
Ah... Ignore me. I'm talking rubbish :)

I hadnt created an inheritance hierarchy at all.. I was feeding an inherited class to a consumer and the consumer was calling Me.GetType(), which was always the consumer. Consumer now calls GetType on the object it is fed..
 
Back
Top