Thanks for the attempt, but this is not what I am looking for. From my original post:
"If I have a Class Animal, is there any way to "convert" it to Monkey without copying over all of the properties?"
Copying over the individual properties can get very cumbersome, and will cause me to go back into the derived classes and update them all individually each time a property is added to the base class.
Because the base class is part of the derived class, I was hoping there was a way to tell .Net to create the derived class, using the base class (and keep the existing data).
Main Topics
Browse All Topics





by: RolandDeschainPosted on 2009-11-05 at 06:05:33ID: 25749519
Mmmm... I don't think this can be done. Probably you must do this:
Public Class Monkey
Inherits Animal
Public Sub New()
'This empty constructor allows you to instance new blank objects of Monkey class
End Sub
Public Sub New(ByVal Parent As Animal)
'This constructor allows you to create a new Monkey object based on an Animal object,
'by copying its properties
With Me
.Name = Parent.Name
.Legs = Parent.Legs
'... and so on
End With
End Sub
End Class
'Later, on your code:
Dim myAnimal As New Animal
'.... set animal properties
Dim myMonkey As New Monkey(myAnimal)
I think this is the right approach.
Hope that helps.