开发者

serialized generic collections

开发者 https://www.devze.com 2023-03-10 11:12 出处:网络
I have serialized XML file. I am reading the contents which is of type Dictionary<string,string> and List<int>.

I have serialized XML file. I am reading the contents which is of type Dictionary<string,string> and List<int>.

How can I retrieve these 2 objects. I tried to use ArayList to hold these 2 objects ,but since arraylist is not generic type, it gave exception.Please help..

if (fs.Length != 0) 
{ 
    BinaryFormatter bf = new BinaryFormatter(); 开发者_StackOverflow中文版
    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();


I think you can just desirialize it as you have serialize it. If you have serialized a Dictionary you can't deserialize a List

0

精彩评论

暂无评论...
验证码 换一张
取 消