EEKstream
July 27th, 2006, 12:12 AM
I have an object, we can call it ClassA, that are to be serialized. It's containing an arraylist. It looks something like this
[Serializable()]
public class ClassA {
private ArrayList list;
public ArrayList List {
// get/set
}
public override void GetObjectData(SerializationInfo info, StreamingContext ctxt)
{
info.AddValue("list", list);
}
}
and also a constructor for the deserialization. The thing is that I store objects of type ClassB in my ArrayList. I've marked this class (ClassB) as Serializable but it does not implement ISerializable or has a GetObjectData method. Now the question is: Why is this working? How can the ArrayList populated with ClassB-objects be serialized when there is no serialize-method for ClassB? Because everything works fine and when I deserialize my object, the arraylist contains the same stuff as it did before the serialization.
[Serializable()]
public class ClassA {
private ArrayList list;
public ArrayList List {
// get/set
}
public override void GetObjectData(SerializationInfo info, StreamingContext ctxt)
{
info.AddValue("list", list);
}
}
and also a constructor for the deserialization. The thing is that I store objects of type ClassB in my ArrayList. I've marked this class (ClassB) as Serializable but it does not implement ISerializable or has a GetObjectData method. Now the question is: Why is this working? How can the ArrayList populated with ClassB-objects be serialized when there is no serialize-method for ClassB? Because everything works fine and when I deserialize my object, the arraylist contains the same stuff as it did before the serialization.