Why is the BinaryFormatter serializing private members and not the XMLSerializer or the SoapFormatter ?

落花浮王杯 提交于 2019-12-13 06:04:05

问题


I recently had a problem concerning serialization of private members of a class. here

The problem was that i tried to serialize private members using XMLSerializer, i also tried the SoapFormatter which couldn't serialize them either. The only reason i wanted to serialize in one of those two formats was that i wanted to be able to check serialized values.

After that, i tried the BinaryFormatter which could serialize private members without any problems.

Why is the BinaryFormatter serializing private members and not the XMLSerializer or the SoapFormatter ?

I'm also wondering, How the BinaryFormatter is able to access the private members of a class?

EDIT

The second question was answered by reflection.

来源:https://stackoverflow.com/questions/21019093/why-is-the-binaryformatter-serializing-private-members-and-not-the-xmlserializer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!