-
-
Save udawtr/1975782 to your computer and use it in GitHub Desktop.
XML serialization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Person Deserialize(string file) | |
{ | |
XmlSerializer serializer = new XmlSerializer(typeof(Person)); | |
Stream reader = new FileStream("C:\\myXmFile.xml", FileMode.Open); | |
Person temp=(Person)serializer.Deserialize(reader); | |
reader.Close(); | |
return temp; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Serialize() | |
{ | |
XmlSerializer serializer = new XmlSerializer(typeof(Person)); | |
Stream writer = new FileStream("C:\\myXmFile.xml", FileMode.Create); | |
serializer.Serialize(writer, this); | |
writer.Close(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Person Deserialize(string file) | |
{ | |
XmlSerializer serializer = new XmlSerializer(typeof(Person)); | |
Stream reader = new FileStream("C:\\myXmFile.xml", FileMode.Open); | |
Person temp=(Person)serializer.Deserialize(reader); | |
reader.Close(); | |
return temp; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Serialize() | |
{ | |
XmlSerializer serializer = new XmlSerializer(typeof(Person)); | |
Stream writer = new FileStream("C:\\myXmFile.xml", FileMode.Create); | |
serializer.Serialize(writer, this); | |
writer.Close(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Person | |
{ | |
public string FirstName {get; set;} | |
public string LastName {get; set;} | |
public int SSNo {get; set;} | |
… | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment