Have a Snippet?

Keep, track and share your code snippets with your friends



C#: DeSerialize object to xml file Share on Vkontakte

DeSerialize object to xml file

private static void DeSerialize()
        {
            try
            {
                var testObject = new TestClass();
                var serializer = new XmlSerializer(testObject.GetType());
                var reader = new StreamReader(Filename);
                var deserialized = serializer.Deserialize(reader.BaseStream);
                testObject = (TestClass)deserialized;
                reader.Dispose();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
           
        }


Tag: deserialize, c#, xml

0 Comments