Programmatically set properties to exclude from serialization

前端 未结 7 1193
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-30 07:19

Is it possible to programmatically set that you want to exclude a property from serialization?

Example:

  • When de-serializing, I want to load up an ID fi
7条回答
  •  醉话见心
    2020-12-30 07:22

    If you are serializing to XML, you can use XMLIgnore

    As in:

    class SomeClass
    {
      [XmlIgnore] int someID;
      public string someString;
    }
    

提交回复
热议问题