Hi Stuart,
Do you really need to know the type of object if they all derive from the
same base class? Surely polymorphism will take care the various
sub-classes?
If you really do need to know the type you could check with the 'is' keyword
and cast accordingly, but that's ugly and you'll have to update it for any
new sub-classes created.
Though it must be said I'm no serialization expert so there may be a cleaner
way...
--Liam.
"StuartM miles @amsjv.com>" <"stuart<dot> wrote in message
news:41**********@baen1673807.greenlnk.net...
On Tue, 9 Nov 2004 13:01:09 -0500, Nicholas Paldino [.NET/C# MVP] wrote:
Stuart,
You shouldn't have a problem with this. The type information is
stored in the stream, and the formatter should be able to pick this up.
All you have to do in your derived class is attach the Serializable
attribute and optionally implement the ISerializable interface.
Hope this helps.
Perhaps I'm making this harder than it really is. AIUI when I deserialize
the object I have to cast it to its correct type, if I don't know which
derived class I've got how do I do the cast?