Last active
August 29, 2015 14:06
-
-
Save margusmartsepp/2df6724bf6134af40fc4 to your computer and use it in GitHub Desktop.
c# Serialize
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static bool Serialize<T>(this T item, string filename) | |
| { | |
| try | |
| { | |
| var ser3 = new XmlSerializer(typeof(T)); | |
| using (var writer = XmlWriter.Create(filename)) | |
| { | |
| ser3.Serialize(writer, item); | |
| } | |
| return true; | |
| } | |
| catch (Exception ex) | |
| { | |
| return false; | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Class to be serialized should be with Public access modifier.