Serialize and Deserialize XML using dot.net c#

后端 未结 2 2007
夕颜
夕颜 2021-01-17 06:07

I have spent the last few hours putting togeather the following code after reading much that seems out of date or that does\'nt quite seem to work.

If its any help t

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-17 07:06

    I think there is no need for the whole Encoding part. You simply serialise using one encoding, then convert to bytes, and then convert back to Unicode. Why is that? But I might be missing something here.

    Another thing that hits me is .ToArray() usage. If you have big hiearchy and serialising lot of objects, this can be pretty performance heavy. Try using StreamReader to read the memory stream without need to copy it into to Array. But this requires some performance testing to back up my reasoning.

提交回复
热议问题