Is it possible to make this code a little more compact by somehow declaring the 2 variable inside the same using block?
using (var sr = new StringReader(content))
{
using (var xtr = new XmlTextReader(sr))
{
obj = XmlSerializer.Deserialize(xtr) as TModel;
}
}
new XmlTextReader()
. UseXmlReader.Create()
– John Saunders Feb 22 '12 at 13:48new XmlTextReader()
has been deprecated since .NET 2.0. By usingXmlReader.Create()
, you will get the best derivedXmlReader
class possible, as opposed to just the oneXmlTextReader
class. – John Saunders Feb 22 '12 at 13:53