I am trying to serialize and deserialize a List of Interface like List; There are some generic classes that inherit this interface like below:
public class BasicQuery<T> : IQuery
{
public T Value{get;set;}
}
I have created several instances of BasicQuery for different datatypes and added to the list
List<IQuery> ListOfQueries = new List<IQuery>();
BasicQuery<int> q1 = new BasicQuery<int>(); q1.Value = 100;
ListOfQueries.Add(q1);
BasicQuery<string> q2 = new BasicQuery<string>(); q2.Value="Test";
ListOfQueries.Add(q2);
My question is how to serialize and deserialize the List of interfaces to xml which is ineherited by generic child classes. I searched around and found one very useful link https://www.codeproject.com/Articles/38930/XML-Serialization-of-a-Class-Inherited-from-Generi?msg=3159064#xx3159064xx . But that still do not solve my problem. Please suggest.