D
deko
I understand I can use System.Xml.Serialization.XmlSerializer to convert an
object to XML, but I'm confused on the mechanics of this.
I have a C# .NET 2.0 Windows Forms app that contains a whole bunch of
user-defined properties that need to be persisted to an XML file. Each set
of properties comprises a "Thing" object.
So let's say I have a class - "Things" - with a dozen or so public
properties. And I create 10 Things. My application has a form in which
users can change the properties of these Things using various controls. So
now the user has carefully adjusted all the properties of his Things, and
then he closes the form and exits the application.
The next time the app is opened, how do I deserialize the Things? Sure, I
can serialize the Things class by marking the class with the [Serializable]
attribute. But how/where do I persist the values for all the properties?
What good is serializing the class? Does that automatically persist the
properties?
And what if I want to instantiate one particular Thing - "MyThing" - how to
I lookup the properties for MyThing and instantiate that one object without
instantiating all Things?
Thanks in advance.
object to XML, but I'm confused on the mechanics of this.
I have a C# .NET 2.0 Windows Forms app that contains a whole bunch of
user-defined properties that need to be persisted to an XML file. Each set
of properties comprises a "Thing" object.
So let's say I have a class - "Things" - with a dozen or so public
properties. And I create 10 Things. My application has a form in which
users can change the properties of these Things using various controls. So
now the user has carefully adjusted all the properties of his Things, and
then he closes the form and exits the application.
The next time the app is opened, how do I deserialize the Things? Sure, I
can serialize the Things class by marking the class with the [Serializable]
attribute. But how/where do I persist the values for all the properties?
What good is serializing the class? Does that automatically persist the
properties?
And what if I want to instantiate one particular Thing - "MyThing" - how to
I lookup the properties for MyThing and instantiate that one object without
instantiating all Things?
Thanks in advance.