Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Why not just use the <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx" rel="nofollow">XmlSerializer</a> Class?</p> <p>You could just create a Patient object. Then serialize and deserialize from it like:</p> <pre><code>[Serializable] public class Patient { public string Name {get; set;} public int Age {get; set;} public int Id {get; set;} public override string ToString() { return Name; } } ... public void Serialize(List&lt;Patient&gt; pList) { using (Stream writer = new FileStream(filename, FileMode.Create)) { var serializer = new XmlSerializer(typeof (List&lt;Patient&gt;)); serializer.Serialize(writer, pList); } } public List&lt;Patient&gt; Deserialize() { using (Stream reader = new FileStream(filename, FileMode.Open)) { var serializer = new XmlSerializer(typeof (List&lt;Patient&gt;)); var pList = (List&lt;Patient&gt;) serializer.Deserialize(reader); return pList; } } </code></pre> <p>Now you can create a patient object like normal, save it with serialize, and load it back into an object with deserialize.</p> <p>You might want to use it like this:</p> <pre><code>public List&lt;Patient&gt; Patients; // Patient collection //Populate your listBox with these patient objects. private void textBox1_LostFocus(object sender, RoutedEventArgs e) { if (listBox1.SelectedItem == null) return; var patient = listBox1.SelectedItem as Patient; // Get the selected PObj; patient.Name = textBox1.Text; Serialize(Patients); //Save the list to xml } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload