Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 序列化泛型集合_C#_Asp.net - Fatal编程技术网

C# 序列化泛型集合

C# 序列化泛型集合,c#,asp.net,C#,Asp.net,我已经序列化了XML文件。我正在阅读字典和列表类型的内容 如何检索这两个对象。 我试图使用ArayList来保存这两个对象,但由于arraylist不是泛型类型,所以出现了异常。请帮助 if (fs.Length != 0) { BinaryFormatter bf = new BinaryFormatter(); ArrayList dstemp = (ArrayList)bf.Deserialize(fs); // Dictionary<string,s

我已经序列化了XML文件。我正在阅读
字典
列表
类型的内容

如何检索这两个对象。 我试图使用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();
if(fs.Length!=0)
{ 
BinaryFormatter bf=新的BinaryFormatter();
ArrayList dstemp=(ArrayList)bf.反序列化(fs);
//Dictionary tempRD=(Dictionary)templast[0];
//List shipto=(List)templast[1];
this.currentFormData.LinkToShipToList=(列表)bf.反序列化(fs);
} 
fs.Close();

我认为您可以将它序列化,因为您已经序列化了它。如果已序列化词典,则无法反序列化列表

语言。和一些代码,你已经做了什么,直到现在你可以添加更多的信息。可能是xml示例。@naveen if(fs.Length!=0){BinaryFormatter bf=new BinaryFormatter();ArrayList dstemp=(ArrayList)bf.Deserialize(fs);//Dictionary tempRD=(Dictionary)TempList[0];//List shipto=(List)TempList[1];this.currentFormData.LinkToShipToList=(列表)bf.Deserialize(fs);}fs.Close();当然,您反序列化到数据序列化的类型,我缺少什么?@Jodrell系统接收到具有类型字典和列表的文件流。现在,如果我反序列化到任何一种类型,它会给出错误。