Maintain object references through Serialize/Deserialize

后端 未结 4 1081
渐次进展
渐次进展 2021-01-20 19:57

When serializing, I would like to serialize an object only once, then any references to that object should be serialized as a reference to the object. This is because, when

4条回答
  •  深忆病人
    2021-01-20 20:39

    Not sure if this is what you would like to hear... But lets just think about what you are trying to do.

    You only have the need to serialize an object when: a) You want to store it somewhere an latter on retrieve the information. b) You want to send the object to another application.

    A reference is nothing more than a pointer to where the object is. So in either case you simply cannot access the memory because in a) it is reserved for your application and in b) it is another machine and it doesn't even exists.

    http://en.csharp-online.net/Glossary:Definition_-_Reference_type

提交回复
热议问题