一个派生类序列化的问题
以上代码 你会发现一个很奇怪的现象,就是第一段直接对派生类序列化不会出错,但是第二段把派生类对象加到集合里进行序列化就会报错:"The type ConsoleApplication4.BillElement was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically."
最后查找资料得知解决方式 如下:
以上代码 你会发现一个很奇怪的现象,就是第一段直接对派生类序列化不会出错,但是第二段把派生类对象加到集合里进行序列化就会报错:"The type ConsoleApplication4.BillElement was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically."
最后查找资料得知解决方式 如下: