Estoy intentando ejecutar código similar al siguiente:interfaces de Serialización
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
namespace ConsoleApplication1
{
[Serializable]
[XmlInclude(typeof(List<Class2>))]
public class Class1
{
private IList<Class2> myArray;
public IList<Class2> MyArray
{
get { return myArray; }
set { myArray = value; }
}
}
public class Class2
{
private int myVar;
public int MyProperty
{
get { return myVar; }
set { myVar = value; }
}
}
class Program
{
static void Main(string[] args)
{
XmlSerializer ser = new XmlSerializer(typeof(Class1), new Type[] { typeof(List<Class2>) });
FileStream stream = File.OpenWrite("Data.xml");
ser.Serialize(stream, new List<Class1>());
stream.Close();
}
}
}
Puede alguien explicarme qué estoy haciendo mal?
me sale un:
No se puede serializar miembro de MiMatriz .. ... porque es una interfaz.
¿No debería el XmlInclude resolver esto?
¿quién dijo algo acerca de deserializar ...? –