當我寫這樣的代碼非序列化物業
[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) –