我有这样的课
public class Record
{
public Int32 TotalTrail { get; set; }
public TimeSpan MyTimeSpan { get; set; }
public DateTime MyDateTime { get; set; }
}
我有一个列表来保存它的对象:
List<Record> _records;
然后当我想序列化列表时:
serializer.Serialize(stream, _records);
上面一行有一个运行时错误:
Cannot assign object of type System.Collections.Generic.List`1[[SimpleGame.Record, SimpleGame, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] to an object of type SimpleGame.Record.
是不是因为我无法序列化列表?我该如何解决这个问题?
最佳答案
您必须为 List<Record>
类型创建序列化程序而不是 Record
关于c# - 如何序列化自定义对象类型列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10868319/