views:

52

answers:

2

how do I include the serialized data from a child class where both impliment iserializeable?

Class A
     Implements ISerializable
     dim _B as new B
     Class B
          Implements ISerializable
          dim _C as integer
     end class
end class

I need to be able to serialize object B's data along with the data that is being serialized via the GetObjectData method for class A. In my use case Class A also happens to be a derived class.

A: 

Only implement ISerializable when you want to customize (or extend) the data that is being serialized. Use the System.SerializableAttribute code attribute instead on both classes and it should work.

MSDN is your friend: http://msdn.microsoft.com/en-us/library/4abbf6k0%28VS.80%29.aspx

obiwanjacobi
that would be great if that was possible but it is not in this case and that does not answer the question at all.
Middletone
A: 

If you mean when you serialize type A, any objects of type B are also serialized then it is not possible.

For this you need to have a mechanism that tracks objects of type B created and also some way to keep relationship between object of type A and type B.

If A or B are used independently of each other then I don't see any need for this.

TheVillageIdiot