1

Possible Duplicate:
Public fields/properties of a class derived from BindingList<T> wont serialize

When I try to serialize this object, only the list property is serialized.

object code:

public class checkList<T>: List<T>
{
        public bool check = true;
        public string path;
        public string type;
}

I have a Instance to serialize:

List<checkList<Keys>> hookKeys;

deserialize code:

FileStream fs = new FileStream("list", FileMode.Open, FileAccess.Read);
XmlSerializer ser = new XmlSerializer(typeof(List<checkList<Keys>>));
hookKeys = (List<checkList<Keys>>)ser.Deserialize(fs);
fs.Close();

serialize code:

FileStream fsK = new FileStream("list", FileMode.Create, FileAccess.Write);
XmlSerializer serK = new XmlSerializer(typeof(List<checkList<Keys>>));
serK.Serialize(fsK, (List<checkList<Keys>>)hookKeys);
fsK.Close();

xml file after the serializing:

<ArrayOfArrayOfKeys xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ArrayOfKeys>
<Keys>X</Keys>
<Keys>Z</Keys>
<Keys>C</Keys>
</ArrayOfKeys>
</ArrayOfArrayOfKeys>

how I serialize the other property too?

Community
  • 1
  • 1
m-schwob
  • 81
  • 1
  • 6
  • What would you expect the resulting XML to look like? – Chris Shain Jun 12 '12 at 21:38
  • 3
    possible duplicate of [Public fields/properties of a class derived from BindingList wont serialize](http://stackoverflow.com/questions/1225750/public-fields-properties-of-a-class-derived-from-bindinglistt-wont-serialize), also [Serializing object that inherits from List](http://stackoverflow.com/questions/4105762/serializing-object-that-inherits-from-listt?rq=1) – Chris Shain Jun 12 '12 at 21:38
  • I want to serilaizing the object property (check, path, type) in the xml file also. – m-schwob Jun 13 '12 at 06:48
  • I thing may be using 'base' and Override List method? but I don't Know which! – m-schwob Jun 13 '12 at 06:53

0 Answers0