首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

c#利用反照,实现将model类变成字符串、再还原成mode对象的功能

2013-01-23 
c#利用反射,实现将model类变成字符串、再还原成mode对象的功能public class UserGiftCardModel{#region 构

c#利用反射,实现将model类变成字符串、再还原成mode对象的功能

public class UserGiftCardModel{#region 构造函数/// <summary>/// 无参构造函数 /// </summary>public UserGiftCardModel(){}/// <summary>        /// 有参构造函数        /// </summary>/// <param name=" _cardnumber">礼品卡号</param>/// <param name=" _password">卡密码</param>/// <param name=" _festivalname">节日名称</param>/// <param name=" _facevalue">面值</param>/// <param name=" _balance">余额</param>/// <param name=" _couponamount">奖励金额</param>/// <param name=" _picture">图片</param>/// <param name=" _title">标题 </param>/// <param name=" _buytime">购买时间</param>/// <param name=" _buyid">购买人ID</param>/// <param name=" _recieveid">接收人ID</param>/// <param name=" _receiveemail">接收者邮箱</param>/// <param name=" _leavewords">留言</param>public UserGiftCardModel(string _cardnumber,string _password,string _festivalname,decimal _facevalue,decimal _balance,decimal _couponamount,string _picture,string _title,DateTime _buytime,int _buyid,int _recieveid,string _receiveemail,string _leavewords)        {        this._cardnumber = _cardnumber;        this._password = _password;        this._festivalname = _festivalname;        this._facevalue = _facevalue;        this._balance = _balance;        this._couponamount = _couponamount;        this._picture = _picture;        this._title = _title;        this._buytime = _buytime;        this._buyid = _buyid;        this._recieveid = _recieveid;        this._receiveemail = _receiveemail;        this._leavewords = _leavewords;        }        #endregion        #region 数据库字段对应的属性      private string _cardnumber = "";/// <summary>/// 礼品卡号        /// </summary>        public string CardNumber        {            get{ return _cardnumber; }            set{ _cardnumber = value; }        }        private string _password = "";/// <summary>/// 卡密码        /// </summary>        public string Password        {            get{ return _password; }            set{ _password = value; }        }        private string _festivalname = "";/// <summary>/// 节日名称        /// </summary>        public string FestivalName        {            get{ return _festivalname; }            set{ _festivalname = value; }        }        private decimal? _facevalue = null;/// <summary>/// 面值        /// </summary>        public decimal? FaceValue        {            get{ return _facevalue; }            set{ _facevalue = value; }        }        private decimal? _balance = null;/// <summary>/// 余额        /// </summary>        public decimal? Balance        {            get{ return _balance; }            set{ _balance = value; }        }        private decimal? _couponamount = null;/// <summary>/// 奖励金额        /// </summary>        public decimal? CouponAmount        {            get{ return _couponamount; }            set{ _couponamount = value; }        }        private string _picture = "";/// <summary>/// 图片        /// </summary>        public string Picture        {            get{ return _picture; }            set{ _picture = value; }        }        private string _title = "";/// <summary>/// 标题         /// </summary>        public string Title        {            get{ return _title; }            set{ _title = value; }        }        private DateTime? _buytime = null;/// <summary>/// 购买时间        /// </summary>        public DateTime? BuyTime        {            get{ return _buytime; }            set{ _buytime = value; }        }        private int? _buyid = null;/// <summary>/// 购买人ID        /// </summary>        public int? BuyID        {            get{ return _buyid; }            set{ _buyid = value; }        }        private int? _recieveid = null;/// <summary>/// 接收人ID        /// </summary>        public int? RecieveID        {            get{ return _recieveid; }            set{ _recieveid = value; }        }        private string _receiveemail = "";/// <summary>/// 接收者邮箱        /// </summary>        public string ReceiveEmail        {            get{ return _receiveemail; }            set{ _receiveemail = value; }        }        private string _leavewords = "";/// <summary>/// 留言        /// </summary>        public string LeaveWords        {            get{ return _leavewords; }            set{ _leavewords = value; }        }        #endregion        #region 根据需要自定义字段        //private string _test = "";        ///// <summary>        ///// 其他字段        ///// </summary>        //public string Test        //{        //    get { return _test; }        //    set { _test = value; }        //}         #endregion        }

已测试过。

热点排行