我正在尝试使用以下代码将自定义对象序列化为 xml:
MatchList matchList = converter.Convert(excelStream);
XmlSerializer xmlSerializer = new XmlSerializer(typeof(MatchList));
StringWriter stringWriter = new StringWriter();
xmlSerializer.Serialize(stringWriter, matchList);
string serializedXml = stringWriter.ToString();
txtResult.Text = serializedXml;
但是我在第二行得到了上面的异常:
匹配列表对象定义为:
public class MatchList
{
public Header Header { get; set; }
[XmlArray("Lists")]
[XmlArrayItem("List")]
public virtual List<List> Lists { get; set; }
}