C#对象序列化

    [Serializable]//对象支持序列化成流
    public class Student
    {
        public string Id { get; set; }

        [XmlIgnore]//序列化成xml时被忽略
        public string Name { get; set; }

        public int Age { get; set; }

        [NonSerialized]//序列化成流对象时被忽略 只能标记字段不能标记属性
        private string address;

        public string Address
        {
            get { return address; }
            set { address = value; }
        }
    }

  

posted @ 2014-04-17 14:16  Moulton  阅读(209)  评论(0编辑  收藏  举报