This is what I'm looking to do:
public class NormalClass
{
[XmlAttribute]
public int Example;
}
[XmlRoot]
public class GenericClass<T> where T : HasXmlElementAttribute
{
[XmlArray]
public List<T> Variables;
}
I thought where T : IXmlSerializable
might work, but it did not.
Is this even possible to do? If so, what is the proper way?
Is there a way to achieve this same goal? Is there a way to only allow classes that can be xml serialized?
Thanks
No, you cannot use generic type constraints to limit the type parameters by what attributes they are decorated with. You can only use generic type constraints to limit type parameters by:
Further Reading: