i have read about the reason why you can’t cast a parent to a child: you can’t cast an ANIMAL to a DOG; it might be a CAT.
But here is my issue:
i receive a data object from my datalayer with 50 properties. Now i created a child object of this object, with only one more property.
And in my function, i want to fill all the 51 properties of my object with the 50 of the base object, and the one extra.
So i’m looking for a way to ‘copy’ the 50 properties of the parent object to the child object.
Is there a way to do it?
This is very possibly a time where you don’t want to use inheritance. To do this have the new Type not inherit from anything and have two properties, one being of the old type (what you’re currently considering using as the parent) and another with the new piece of data.