[XmlIgnore] [NonSerialized] public List<string> paramFiles { get; set; } //I get the following error: //Attribute 'NonSerialized' is not valid on this declaration type. It is only valid on 'field' declarations.
[AttributeUsageAttribute(AttributeTargets.Field, Inherited = false)] [ComVisibleAttribute(true)] public sealed class NonSerializedAttribute : Attribute
I suggest using backing fieldhtml
public List<string> paramFiles { get { return list;} set { list = value; } } [NonSerialized] private List<string> list;
參考:https://stackoverflow.com/questions/7693391/nonserialized-on-propertypost
延伸:http://www.javashuo.com/article/p-yuhsvvvj-bd.html Json序列化指定輸出字段 忽略屬性this