Last active
August 29, 2015 14:06
-
-
Save margusmartsepp/23c71cdbc6935fd18d90 to your computer and use it in GitHub Desktop.
Deserialize xml
This file contains 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 Deserialize<T>(this String str, out T item) | |
{ | |
item = default(T); | |
try | |
{ | |
using (var reader = XmlReader.Create(new StringReader(str))) | |
{ | |
item = (T)new XmlSerializer(typeof(T)).Deserialize(reader); | |
} | |
return true; | |
} | |
catch (Exception ex) | |
{ | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment