I want to change my code from:
string path = @\"c:\\Directory\\test.xml\"; XmlSerializer s = new XmlSerializer(typeof(Car)); TextReader r = new StreamReader
1-liner, takes a XML string text and YourType as the expected object type. not very different from other answers, just compressed to 1 line:
text
YourType
var result = (YourType)new XmlSerializer(typeof(YourType)).Deserialize(new StringReader(text));