最佳答案
当我编写这样的代码时
[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]
?