我只有一个简单的问题。我将一个字符串列表保存到了我的IsolatedStorageSettings,但我不知道如何阅读它们。 你能救我吗?
IsolatedStorageSettings episodename = IsolatedStorageSettings.ApplicationSettings;
List<string> episodelist = new List<string>();
episodelist.Add(Beschreibung);
episodename.Add("test", episodename);
episodename.Save();
Beschreibung和episodename是两个字符串。
答案 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
}