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
Add a 'class' constraint (or more detailed, like a base class or interface of your exepected T objects):
private static T ReadData(XmlReader reader, string value) where T : class
{
reader.MoveToAttribute(value);
object readData = reader.ReadContentAsObject();
return (T)readData;
}
or where T : IMyInterface
or where T : new()
, etc