How do I use XmlSerializer to insert an xml string

前端 未结 4 1355
伪装坚强ぢ
伪装坚强ぢ 2020-12-10 15:15

I have defined the following class:

public class Root
{
    public string Name;
    public string XmlString;
}

and created an object:

4条回答
  •  佛祖请我去吃肉
    2020-12-10 15:34

    I would be very surprised if this was possible. Suppose it was possible for you to do this - what would happen if you had malformed XML in the property - everything would just break.

    I expect that you will either need to write your own serialization for this case, or make it so that the XmlString field is a structure that contains a foo field.

提交回复
热议问题