Windows Phone 8 - 将列表保存到IsolatedStorage

时间:2013-08-06 08:05:07

标签: c# silverlight windows-phone-8 windows-phone

我正在尝试保存属于我班级类型的对象集合。我收到一个错误说明:

  

集合数据协定类型'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()
        {
        }
    }
}

以下是我如何保存到IsolatedStorage:

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

1 个答案:

答案 0 :(得分:6)

让课程公开

public class Lekarna