Serialize and Deserialize XML using dot.net c#

后端 未结 2 2031
夕颜
夕颜 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:09

    I suggest moving the type parameter T to the enclosing class and making the XmlSerializer instance static. A static field in a generic class is per closed type, so SerializationHelper and SerializationHelper will each have separate instances of the field.

    Also, I'm not sure that catch { return String.Empty; } is the best idea either -- masking problems to avoid crashing makes me nervous.

提交回复
热议问题