我可以序列化匿名类型为XML?类型、序列化、XML

2023-09-02 10:24:50 作者:嗯哼′别吵

我了解,匿名类型标记为私有的编译器和属性是只读的。有没有办法将它们序列化到XML(不含反序列化)?它works使用JSON ,我怎么能做到这一点与XML?

I understood that anonymous types are marked private by the compiler and the properties are read-only. Is there a way to serialize them to xml (without deserialize) ? It works with JSON, how can I do it with XML?

推荐答案

对不起,你不能。 XML序列pretty的简单,只是序列化的公共读写类型。

Sorry, you cannot. The XML Serializer pretty much just serializes public read-write types.

请注意,我的反应是如何使用XML序列化。您可以与其他串行成功,特别是尝试用数据协定序列化。

Note that my response is about using the XML Serializer. You may succeed with other serializers, in particular, try it with the Data Contract Serializer.