I\'m parsing an XML file with the XmlReader class in .NET and I thought it would be smart to write a generic parse function to read different attributes generic
XmlReader
First check to see if it can be cast.
if (readData is T) { return (T)readData; } try { return (T)Convert.ChangeType(readData, typeof(T)); } catch (InvalidCastException) { return default(T); }