序列化的泛型集合

本文关键字:集合 泛型 序列化 | 更新日期: 2023-09-27 17:58:24

我已经序列化了XML文件。我正在阅读Dictionary<string,string>List<int>类型的内容。

如何检索这2个对象。我试图使用ArayList来保存这两个对象,但由于arraylist不是泛型类型,所以它给出了异常。请帮忙。。

if (fs.Length != 0) 
{ 
    BinaryFormatter bf = new BinaryFormatter(); 
    ArrayList dstemp = (ArrayList)bf.Deserialize(fs); 
    // Dictionary<string,string> tempRD = (Dictionary<string,string>) TempList[0]; 
    // List<int> shipto = (List<int>)TempList[1]; 
    this.currentFormData.LinkToShipToList = (List<int>)bf.Deserialize(fs); 
} 
fs.Close();

序列化的泛型集合

我认为你可以像序列化它一样取消序列化它。如果你已经序列化了Dictionary,你就不能反序列化List