The question I have involves 3 basic objects, (1)a class that contains methods to serialize and deserialize another class that is then saved to a file on a disk, (2)a class that contains methods and values that is marked serializable and is the class that is serialized to disk and (3)an interface that the serialized class utilizes.

So, here's the question. If the class that is marked serializable contains the following method which is defined in the interface it inherits from:

public int MyMethod()
{
    Return 1;
}

is serialized to a file successfully, and then later on, an update to the software is made. In the update, the interface remains the same, as does the class that contains methods to serialize and deserialize the file, but the class that can be serialized earlier is now different, and is now:

public int MyMethod()
{
    Return 0;
}

when the method that deserializes the old serialized file that returns 1, is run and the class object is returned and I call MyMethod() will it return 1 still?

I guess the question could also be asked, when a class is serialized, are the methods, properties and entire structure of the class preserved as well?

I would really appreciate any help anyone might have to offer!

Happy turkey day to everyone by the way!

Recommended Answers

All 2 Replies

No, only variables in a class are serialized, methods are not.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.