问题
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