将数据加载到几个列表
Load data to few lists
try
{
using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream stream = myIsolatedStorage.OpenFile("Reminders.xml", FileMode.Open))
{
XmlSerializer serializer = new XmlSerializer(typeof(List<Reminders>));
remind = (List<Reminders>)serializer.Deserialize(stream);
List2 = (List<Reminders>)serializer.Deserialize(stream);
}
}
}
catch { }
如何在不每次从内存中读取数据的情况下将相同的数据添加到列表中?
可以通过以下方式使用 Linq 完成。
remind = (List<Reminders>)serializer.Deserialize(stream);
List2 = remind.ToList();
try
{
using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream stream = myIsolatedStorage.OpenFile("Reminders.xml", FileMode.Open))
{
XmlSerializer serializer = new XmlSerializer(typeof(List<Reminders>));
remind = (List<Reminders>)serializer.Deserialize(stream);
List2 = (List<Reminders>)serializer.Deserialize(stream);
}
}
}
catch { }
如何在不每次从内存中读取数据的情况下将相同的数据添加到列表中?
可以通过以下方式使用 Linq 完成。
remind = (List<Reminders>)serializer.Deserialize(stream);
List2 = remind.ToList();