state of an object

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ventsislav
    New Member
    • Mar 2009
    • 16

    state of an object

    How can I easily serialize (and deserial.) the items in a combo box?

    Code:
        class Program
        {
            static void Main(string[] args)
            {
                Form1 f = new Form1();
    
                f.comboBox1.Items.Add(new object[] {"Item1", "Item2"});
    
                XmlSerializer XmlSerial = new XmlSerializer(f.comboBox1.Items.GetType());
    
                XmlSerial.Serialize(Console.Out, f.comboBox1.Items);
            }
        }
    It doesn' t work. And when I make it, I suppose I have to save the stream in a file, not in the Console output. What has to be this file, xml??
    Last edited by numberwhun; Jul 28 '09, 05:00 AM. Reason: Please use code tags
  • GaryTexmo
    Recognized Expert Top Contributor
    • Jul 2009
    • 1501

    #2
    Here's the link to the XML Serialization tutorial I followed when I was looking into this...


    I found it worked great and had no problems at all. The example near the bottom shows you how to write to a file.

    As for the actual serialization.. . what error does it give you? I would have thought it would work, at least on my first glance at it.

    Comment

    Working...