【问题标题】:Windows Phone 8 - Saving a List to IsolatedStorageWindows Phone 8 - 将列表保存到独立存储
【发布时间】:2013-08-06 08:05:07
【问题描述】:

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

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

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


【解决方案1】:

公开课程

public class Lekarna

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-11-16
    • 1970-01-01
    • 2013-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多