public void 物品持久化(string 物品, int 数量) { //持久化对象 Good_materials gd; GoodDataSave save = new GoodDataSave(); //先读取json中物品的数据 Dictionary <string, Good_materials> D_gd = save.Load(); //无则新建 gd = new Good_materials(物品, 数量); //有则修改 if (D_gd != null && D_gd.ContainsKey(物品)) { Good_materials temp = D_gd[物品]; gd = new Good_materials(temp.g_name, temp.get_num + 数量); } save.Save(gd); }