Set The “NonSerializedAttribute” To An Auto Property

前端 未结 7 2335
青春惊慌失措
青春惊慌失措 2021-02-18 18:59

This cannot be done in C#. Any way to do it?

...

laugh, in case my little pun wasn\'t understood, what I mean is: how can I mark a property in C# as Non

7条回答
  •  深忆病人
    2021-02-18 19:17

    I theory yes, it's possible. In practical nope, not possible.

    Serialization classes only works on private fields. When you define a auto property; at behind the scenes compiler automatically generates a private field for it. That means this is a language feature not a .net framework feature.

    Also serialization classes are included in redbits, which is any change prohibited due compatibility except bug fixes.

    I hope thats helps.

提交回复
热议问题