赞
踩
将开发过程中经常用的内容段收藏起来,如下的资料是关于C#自定义序列化 ISerializable 的实现的内容,希望对小伙伴有些帮助。
[Serializable] public class BaseObject { [OptionalField] private string _str = "I am BaseObject"; } [Serializable] public class TestObject : BaseObject, ISerializable { int a; string strName = ""; Color c = Color.Red; DataTable _dtColors = null; [OptionalField] ArrayList list = new ArrayList(); [OptionalField] List<int> list1 = new List<int>(); [OptionalField] Dictionary<int, string> dic = new Dictionary<int, string>(); [SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter = true)] protected TestObject(SerializationInfo info, StreamingContext context) { #region 如果基类也实现了ISerializable接口,则序列化器会自动调用基类的该构造函数,就不需要本段代码
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。