开发者

ObjectSerializer.SerializeObject and nested classes

I开发者_开发知识库f I have a class with many child classes and I use ObjectSerializer.SerializeObject will it also serialize the child classes as well?


Serializers do not serialize classes. They serialize instances (and graphs of instances).

An instance of a class does not automatically contain an instance of any of its nested classes. Similarly, an instance of the nested class also does not automatically contain an instance of the outer class.

If you serialize an instance of the outer class, the serializer will serialize an instance of the nested class if and only if the object graph contains one. In this respect, nested classes are exactly the same as all other classes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜