当我写这样的代码时
[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]
?
最佳答案
简单使用:
[XmlIgnore]
[ScriptIgnore]
public List<string> paramFiles { get; set; }
希望对您有所帮助。
关于c# - 非序列化属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7693391/