Windows Phone IsolatedStorage设置列表

时间:2014-05-29 19:52:53

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

我只有一个简单的问题。我将一个字符串列表保存到了我的IsolatedStorageSettings,但我不知道如何阅读它们。 你能救我吗?

IsolatedStorageSettings episodename = IsolatedStorageSettings.ApplicationSettings;
List<string> episodelist = new List<string>();
episodelist.Add(Beschreibung);
episodename.Add("test", episodename);
episodename.Save();

Beschreibung和episodename是两个字符串。

2 个答案:

答案 0 :(得分:0)

你可以这样做:

IsolatedStorageSettings episodename = IsolatedStorageSettings.ApplicationSettings;
List<string> read = null;
if (episodename.Contains("test")) read = (List<string>)episodename["test"];

除此之外,你的代码也有错误:

episodename.Add("test", episodename); // this line should be:
episodename.Add("test", episodelist);

在其他情况下,您会收到异常,因为很难序列化IsolatedStorageSettings类。

答案 1 :(得分:0)

我从IsolatedStorageSettings中获取我的值,如下所示:

IsolatedStorageSettings episodename = IsolatedStorageSettings.ApplicationSettings;
List<string> episodelist;
if (episodename.TryGetValue("test", out episodelist))
{     
      // Do something with episodelist
}