gpt4 book ai didi

c# - LinkedList 不能序列化?

转载 作者:行者123 更新时间:2023-11-30 13:29:08 25 4
gpt4 key购买 nike

这是我的类(class):http://pastebin.com/3dc5Vb1t

当我尝试运行时

BookStore b = new BookStore();
b.LoadFromXML(Server.MapPath("list.xml"));
Label1.Text = b.ToString();

我收到以下错误:

You must implement a default accessor on System.Collections.Generic.LinkedList`1[[Book, App_Code.cxsacizw, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]] because it inherits from ICollection.

错误来源是XmlSerializer s = new XmlSerializer(typeof(BookStore));

当我试图在google上寻找解决方案时,我发现LinkedList在序列化方面存在一些问题。我该如何处理?

非常感谢。

最佳答案

看来这不可能。

错误报告在这里:linkedlist-t-can-not-be-serialized-using-the-xmlserializer .您可以在哪里阅读以下内容:

Posted by Microsoft on 11/11/2004 at 19:35
We chose not to have a indexer method on LinkedList for performance reason. So LinkedList will not be XMLSeriliazable.

关于c# - LinkedList 不能序列化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2483268/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com