序列化

序列化


1.什么是“序列化”?

2.简单序列化实例?


1.什么是“序列化”?

http://msdn.microsoft.com/en-us/library/7ay27kt9(v=VS.71).aspx

Serialization is the process of converting the state of an object into a form that can be persisted or transported. The complement of serialization is deserialization, which converts a stream into an object. Together, these processes allow data to be easily stored and transferred.Serialization提供一种讲一个class持久化的能力。


2.简单序列化实例?

上面的代码中需要注意:

1.添加Serializable标记,显式表明该类能够序列化

2.如果类中的某个成员处于性能等考虑的话, 不想被序列化,需要标记NonSerialized

3.如果表明某个对象不被序列化,那么在反序列化生成的对象中该属性是theSums空的。如果想要在反序列化之后重新初始化这些数据,需要实现IDeserializationCallback接口,在这里仅仅是重新计算sums。


本系列的博客均是在学习过程中的个人的感悟,其中难免存在不足之处,欢迎指正,留言提出您的宝贵意见。

posted @ 2011-01-02 16:30  qiang.xu  阅读(263)  评论(0编辑  收藏  举报