Skip to content

Instantly share code, notes, and snippets.

@margusmartsepp
Last active August 29, 2015 14:06
Show Gist options
  • Save margusmartsepp/23c71cdbc6935fd18d90 to your computer and use it in GitHub Desktop.
Save margusmartsepp/23c71cdbc6935fd18d90 to your computer and use it in GitHub Desktop.
Deserialize xml
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