• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

风语者

风中我低语,愈远愈清晰
  • 博客园
  • 联系
  • 管理

公告

View Post

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;
}

 

posted on 2005-08-22 17:20  风语者  阅读(1007)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3