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