当我尝试序列化这个对象时,只有 list 属性被序列化。
对象代码:
public class checkList<T>: List<T>
{
public bool check = true;
public string path;
public string type;
}
我有一个要序列化的实例:
List<checkList<Keys>> hookKeys;
反序列化代码:
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();
序列化代码:
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文件:
<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>
我如何也序列化其他属性?