4.3 序列化 Serialization
1. 總是標記未封裝的類為[Serializable]
Always mark non-sealed classes as serializable.
2. 總是標記未序列化的成員變量為[non-serializable]
Always mark un-serializable member variables as non-serializable.
3. 總是標記序列化類中的委托為[NonSerialized]
Always mark delegates on a serialized class as non- serializable fIElds.
[Serializable]
public class MyClass
{
[fIEld: NonSerialized]
public event EventHandler MyEvent;
}