Question

In my object graph, I have something like

[Serializable]
public class Dog 
{
     string _name;
}

and I have all sorts of lists of Dogs and reference to Dogs.

Since Dog was only animal at the start of the software creation, I didn't have a need for any base class. Now, that need has emerged and now I would like to have

[Serializable]
public class Dog : Animal
{
    public void Bark() { }
}

[Serializable]
public class Cat : Animal
{
    public void DoTheCatStuff() { }
}

[Serializable]
public class Animal 
{
     string _name;
}

BUT: when I deserialize OLD archive, I don't have any dogs. They didn't deserialize from the archive at all.

What I would like is some advice on how to do it. If I'll need new class hierarchy and manually copy the objects from the old Dog to the new TheDog, fine, but would like to avoid it if possible.

EDIT: Some .NET gurus, WHY don't I have any Dogs?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top