Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.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#使用<;保存字典;字符串,列表<;字符串>&燃气轮机;使用Binaryformatter(或其他内容)的in.dat FileStream fs=newfilestream(“answers.dat”,FileMode.Create); 字典聊天=新建字典(); BinaryFormatter formatter=新的BinaryFormatter(); 公开作废开始() { chats=(字典)格式化程序。反序列化(fs);//出现错误 fs.Close(); }_C#_List_Dictionary_Chatbot - Fatal编程技术网

c#使用<;保存字典;字符串,列表<;字符串>&燃气轮机;使用Binaryformatter(或其他内容)的in.dat FileStream fs=newfilestream(“answers.dat”,FileMode.Create); 字典聊天=新建字典(); BinaryFormatter formatter=新的BinaryFormatter(); 公开作废开始() { chats=(字典)格式化程序。反序列化(fs);//出现错误 fs.Close(); }

c#使用<;保存字典;字符串,列表<;字符串>&燃气轮机;使用Binaryformatter(或其他内容)的in.dat FileStream fs=newfilestream(“answers.dat”,FileMode.Create); 字典聊天=新建字典(); BinaryFormatter formatter=新的BinaryFormatter(); 公开作废开始() { chats=(字典)格式化程序。反序列化(fs);//出现错误 fs.Close(); },c#,list,dictionary,chatbot,C#,List,Dictionary,Chatbot,现在是否有其他选项将词典保存(以及稍后再次加载)到文件中^^ 谢谢你的帮助 Paul:)我会使用,独立于程序集版本的更改,并生成可读的文本 FileStream fs = new FileStream("Answears.dat", FileMode.Create); Dictionary<string, List<string>> chats = new Dictionary<string, List<string>>();

现在是否有其他选项将词典保存(以及稍后再次加载)到文件中^^

谢谢你的帮助

Paul:)

我会使用,独立于程序集版本的更改,并生成可读的文本

     FileStream fs = new FileStream("Answears.dat", FileMode.Create);
     Dictionary<string, List<string>> chats = new Dictionary<string, List<string>>();

     BinaryFormatter formatter = new BinaryFormatter();
     public void Start()
    {

                chats = (Dictionary<string, List<String>>) formatter.Deserialize(fs); //here is a error 
                fs.Close();

    }
稍后,您可以将其加载为

File.WriteAllText(filename, JsonConvert.SerializeObject(yourDict));
var yourDict=JsonConvert.DeserializeObject(File.ReadAllText(filename));
我会使用,独立于程序集版本更改,并生成可读文本

     FileStream fs = new FileStream("Answears.dat", FileMode.Create);
     Dictionary<string, List<string>> chats = new Dictionary<string, List<string>>();

     BinaryFormatter formatter = new BinaryFormatter();
     public void Start()
    {

                chats = (Dictionary<string, List<String>>) formatter.Deserialize(fs); //here is a error 
                fs.Close();

    }
稍后,您可以将其加载为

File.WriteAllText(filename, JsonConvert.SerializeObject(yourDict));
var yourDict=JsonConvert.DeserializeObject(File.ReadAllText(filename));
请参阅或。相关:。请参阅或。相关:。