LinkedList无法序列化?(LinkedList cannot be serialised?)
这里是我的课程: http : //pastebin.com/3dc5Vb1t
当我尝试跑步时
BookStore b = new BookStore(); b.LoadFromXML(Server.MapPath("list.xml")); Label1.Text = b.ToString();
我收到以下错误:
您必须在System.Collections.Generic.LinkedList`1 [[Book,App_Code.cxsacizw,Version = 0.0.0.0,Culture = neutral,PublicKeyToken = null]]上实现默认访问器,因为它从ICollection继承。
错误来源是
XmlSerializer s = new XmlSerializer(typeof(BookStore));
当我试图在google上寻找解决方案时,我发现LinkedList在序列化方面存在一些问题。 我该如何处理它?
非常感谢你。
Here are my classes: http://pastebin.com/3dc5Vb1t
When I try to run
BookStore b = new BookStore(); b.LoadFromXML(Server.MapPath("list.xml")); Label1.Text = b.ToString();
I get the following error:
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.
The error source is
XmlSerializer s = new XmlSerializer(typeof(BookStore));
When I tried to look for a solution on google, I found it that LinkedList has some problems with serialization. How can I deal with it?
Thank you very much.
原文:https://stackoverflow.com/questions/2483268
最满意答案
相关问答
更多-
尝试这个: import re re.split(r'[,;]+', 'This,is;a,;string') > ['This', 'is', 'a', 'string'] Try this: import re re.split(r'[,;]+', 'This,is;a,;string') > ['This', 'is', 'a', 'string']
-
split_regex建议split_regex很好。 如果你不想处理正则表达式,你可以使用ifind_all算法,如这个例子所示。 你接收到你分隔符的所有事件的iterator_range (开始/结束)。 您的令牌位于它们之间(以及字符串的开头和结尾)。 split_regex as suggested by @Mythli is fine. If you don't want to deal with regex, you can use ifind_all algo, as is shown in ...
-
使用替代: #var2=(.*?)(\n|$)# ^ ^^^ Use alternation: #var2=(.*?)(\n|$)# ^ ^^^
-
您可以设置内部字段分隔符 (IFS)变量,然后将其解析为数组。 当在命令中发生这种情况时, IFS的分配仅发生在该命令的环境中(要read )。 然后,它将根据IFS变量值的输入解析成数组,然后我们可以迭代。 IFS=';' read -ra ADDR <<< "$IN" for i in "${ADDR[@]}"; do # process "$i" done 它将解析一行分开的项目; ,将其推入阵列。 处理整个$IN ,每次输入一行输入; : while IFS=';' read -ra A ...
-
简单的方法 只需使用string-right-trim : (string-right-trim " ,.;!?/" s) 你的错误 如果将空字符串传递给del-delimiter-at-end ,则会将-1作为第二个参数传递给char 。 你的守则 没有理由这样做(eq (delimiterp ...) nil) ; 只需使用(delimiterp ...)代替(并切换子句!) 当你只有两个条款并且每个只有一个表格时,使用if和not cond是模式惯用语。 你subseq递归方式调用subseq ,这 ...
-
代替希望它与预期匹配的代码,通常先理解代码片段通常会更好。 split :: String -> [String] split [] = [""] split (c:cs) | c == ',' = "" : rest | otherwise = (c : head rest) : tail rest where rest = split cs 首先,我们更好地分析一下split 。 第一条语句简单地说:“ 一个空字符串的分割,是一个包含一个元素的列表,空字符串 ”。 ...
-
纯粹的bash解决方案: $ foo="silly/horse/fox" $ echo ${foo##*/} fox $ foo="silly/horse/fox/lion" $ echo ${foo##*/} lion 使用sed : $ echo "silly/horse/fox/lion" | sed 's#.*/##' lion Pure bash solution: $ foo="silly/horse/fox" $ echo ${foo##*/} fox $ foo="silly/horse ...
-
当你用<<<和结尾分隔符填充一个字符串时,它叫什么名字?(What is it called when you can fill a string with <<< and an end-delimiter?)[2022-06-19]
它在PHP中被称为HEREDOC语法: It's called the HEREDOC syntax in PHP: -
如何将一个字符串拆分为两个字符分隔符的行(How to split a string into two lines with a two character delimiter)[2023-07-19]
关于什么: awk -F ".>" '{print $1}' awk -F ".>" '{$1=""; print}' ? :) What about: awk -F ".>" '{print $1}' awk -F ".>" '{$1=""; print}' ? :) -
你可以这样做 String[] split = string.split("\\^", -1); 并且它不会丢弃尾随分隔符。 如果你真的想修剪最后一个分隔符以获得12个值,你可以这样做 String[] split = string.replaceAll("\\^$", "").split("\\^", -1); 或者这将确保你总是有12个。它将根据需要修剪或扩展元素数量(如果扩展则添加null ) String[] split = Arrays.copyOf(string.split("\\^", - ...