Reputation: 6359
Until now, I only had to store application state of primitive types like int, string, boolean and for that I used Properties.Settings.Default
object with no problem.
But now I also need to store instances of classes created with new
keyword.
So my question is how to store these types of objects?
Upvotes: 2
Views: 750
Reputation: 11395
Serialize your object with XmlSerializer in that way:
var p=new Person();
p.FirstName = "Jeff";
p.MI = "A";
p.LastName = "Price";
System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(p.GetType());
x.Serialize(Console.Out, p);
Source and full example: http://support.microsoft.com/kb/815813
For the complete process - serializing and deserializing - visit this link:
http://sharpertutorials.com/serialization/
Notes:
Upvotes: 2
Reputation: 62286
You can use msdn: ObjectSerialization.
You have to read a couple of articles in order to select right serialization mechanism for your objects.
Regards.
Upvotes: 1