将数据加载到少数列表

时间:2015-01-13 15:05:27

标签: c# list memory windows-phone

       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 { }

如何以这种方式将相同的数据添加到列表中而不必每次都从内存中读取数据?

1 个答案:

答案 0 :(得分:1)

可以通过以下方式与Linq完成。

remind = (List<Reminders>)serializer.Deserialize(stream);
List2 = remind.ToList();