Hi,
I'm trying to serialize an object which contains an object which implements IEnumerable<>. The last object also contains an object which implements IEnumerable<>. The objects strucutre is as followed:
[Serializable]
public class A
{
public B _b {get; set; }
}
[Serializable]
public class B : IEnumerable<C>
{
public List<C> c_items {get; set;}
public void Add (C obj){}
}
[Serializable]
public class C : IEnumerable<D>
{
public List<D> d_items {get; set;}
public void Add (D obj){}
}
[Serializable]
public class D
{
public int Key {get; set;}
public int Value {get; set;}
}
In the code line:
A obj = new A();
XmlSerializer serializer = new XmlSerializer(obj.GetType());
I'm getting the exception: unable to generate temporary class (result=1), error CS0030: Cannot convert type 'C' to type 'D'...
When I remove the IEnumerable implementation from one of B or C, the serialization works.
What as I getting wrong?
Any help would be appreciated!