Windows Phone 8 - 将列表保存到独立存储中

4
我正在尝试保存一个属于我的类的对象集合。但我遇到了以下错误:

不能反序列化集合数据协定类型'System.Collections.Generic.List',因为它没有公共无参数构造函数。添加一个公共无参数构造函数将解决此错误。

这是我的类:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MojProjekt
{
    class Lekarna
    {
        public string Ime { get; set; }

        public Lekarna()
        {
        }
    }
}

这里是我如何保存到独立存储空间的方法:

List<Lekarna> lekarneList = new List<Lekarna>();  
// here I then fill the list ...  
IsolatedStorageSettings localStorage = IsolatedStorageSettings.ApplicationSettings;
localStorage.Add("lekarneList", lekarneList;
localStorage.Save();

当我尝试像你所做的那样将列表保存在独立存储中时,我会收到System.ArgumentException错误。 - Kinjan Bhavsar
1个回答

6
使这个类变为公共类。 public class Lekarna

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接