当我写这样的代码非序列化物业
[XmlIgnore]
[NonSerialized]
public List<string> paramFiles { get; set; }
我收到以下错误:
Attribute 'NonSerialized' is not valid on this declaration type.
It is only valid on 'field' declarations.
如果我写
[field: NonSerialized]
我得到以下警告
'field' is not a valid attribute location for this declaration.
Valid attribute locations for this declaration are 'property'.
All attributes in this block will be ignored.
如果我写
[property: NonSerialized]
我得到以下错误(再次):
Attribute 'NonSerialized' is not valid on this declaration type.
It is only valid on 'field' declarations.
我怎样才能在财产使用[NonSerialized]
?
可能的重复[如何将属性标记为不可序列化的json?](http://stackoverflow.com/questions/5103200/how-to-mark-a-property-as-non-serializable-for- json) –