我有一个包含多个字符串的列表,我想将其保存到 IsolatedStorage。做一些显而易见的事情,比如
List<string> l = new List<string>();
ApplicationData.Current.LocalSettings.Values["locations"] = l;
导致 Data of this type is not supported
错误。
据我所知,为 WP8 silverlight 改编此代码效果很好。我做错了什么?
最佳答案
ApplicationData.Current.LocalSettings仅支持 base data types .
想想如果你有一个简单的List<string>
,您可以使用 Linq:
List<string> l = new List<string>(); // your list with strings
ApplicationData.Current.LocalSettings.Values["locations"] = l.ToArray();
// then when you want to retrive it:
List<string> lret = ((string[])ApplicationData.Current.LocalSettings.Values["locations"]).ToList();
关于c# - 将列表(String)保存到应用程序/隔离存储(Win8.1),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25151275/