C# 代码标准 .NET2.0版(五)序列化Serialization 编码指导方针

 

1.Prefer the binary formatter.

2.Mark serialization event-handling methods as private.

3.Use the generic IGenericFormatter interface.

4.Always mark non-sealed classes as serializable.

5.When implementing IDeserializationCallback on a non-sealed class, make sure to do so in a way that allows subclasses to call the base class implementation of OnDeserialization( ).

6.Always mark unserializable member variables as non-serializable.

7.Always mark delegates on a serialized class as non-serializable fields:

[Serializable]
public class MyClass
{
   [field:NonSerialized]
   public event EventHandler MyEvent;
}

 

你可能感兴趣的:(serialization)