Benutzer:MovGP0/.NET/Serialization
aus Wikipedia, der freien Enzyklopädie
< Benutzer:MovGP0
Dies ist die aktuelle Version dieser Seite, zuletzt bearbeitet am 4. Mai 2017 um 16:31 Uhr durch imported>MovGP0(77247) (→Intro).
MovGP0 | Über mich | Hilfen | Artikel | Weblinks | Literatur | Zitate | Notizen | Programmierung | MSCert | Physik |
SerializationAttribute
Immutable Serialization
[ImmutableObject(true)]
public class Address: IXmlSerializable
{
private Address()
{
}
public Address(string city, string street, int house)
{
this.City = city;
this.Street = street;
this.HouseNumber = house;
}
public string City { get; private set; }
public string Street { get; private set; }
public int HouseNumber { get; private set; }
#region IXmlSerializable Members
public XmlSchema GetSchema()
{
return null;
}
public void ReadXml(XmlReader reader)
{
this.City = reader.ReadElementString();
this.Street = reader.ReadElementString();
this.HouseNumber = int.Parse(reader.ReadElementString());
}
public void WriteXml(XmlWriter writer)
{
writer.WriteElementString("City", this.City);
writer.WriteElementString("Street", this.Street);
writer.WriteElementString("HouseNumber", this.HouseNumber.ToString());
}
#endregion
}
Referenzen
|