Serialization List with object that has in members objects of List
I want to ask, can I serialize something like this:
class A
{
public A a;
}
A a1 = new A();
A a2 = new A();
a1.a = a2;
a2.a = a1;
List<A> aList = new List<A>(){a1,a2开发者_开发百科};
I want to serialize aList, does after deserialization a1.a == a2 and a2.a == a1 ??
It's called a circular reference (http://en.wikipedia.org/wiki/Circular_reference) and some serializers allow this. If a serializer serializes objects in-place, the serialized result would be of infinite length.
The serializer would have to serialize the reference to the object, instead of the object contents in-place, by keeping a reference table during serialization.
精彩评论