Search code examples
c#listmemorywindows-phone

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

How to add the same data to the lists in this way without reading data from memory each time?


Solution

  • It could be done with Linq in the following way.

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