I have an object that I'm serializing (binary) that contains other internal
objects that are also serialized. The Object contains two other member
objects (let's call them source, and depend) one of which has a state that
depends value is derived from source. My question is (if this can be
generalized) is faster/better to serialize both objects or to only serialize
state and then during deserialization create depend from source.
Option 1:
[Serializable()]
public class Foo
{
object source;
object depend;
protected Foo(SerializationInfo info, StreamingContext context) :
base(info, context)
{
}
}
Option 2:
[Serializable()]
public class Foo
{
object source;
[field:NonSerialized()]
object depend;
protected Foo(SerializationInfo info, StreamingContext context) :
base(info, context)
{
depend = new depend();
depend.State = source.Info;
}
}
Thanks