开发者

Changing what a property is serialized as

开发者 https://www.devze.com 2022-12-25 08:00 出处:网络
I think i already know the answer to this, but i cannot find anything that states it definitively, hence my question - i want to make sure i am not missing a trick.

I think i already know the answer to this, but i cannot find anything that states it definitively, hence my question - i want to make sure i am not missing a trick.

Using the DataContractSerializer or the XmlSerializer, is there any way to change what a pulic property is serialized as? I have a property tha开发者_如何学编程t is an Enum, and i would like it to be serialized as an int, so that its value is sent across the wire instead of a text representation of its value. Is it possible to do this using attributes, or will i have to write my own serializer?

Thanks :)


Probably that's what are you looking for: XmlEnum. You can specify what should be saved during serialization for each enum value.

0

精彩评论

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

关注公众号