문제

Do i have to put [NonSerialized] for each property of a class?

[NonSerialized]
public Cell Owner;
[NonSerialized]
public double Time
도움이 되었습니까?

해결책

If you look at the attribute definition (http://msdn.microsoft.com/en-us/library/system.nonserializedattribute.aspx):

[AttributeUsageAttribute(AttributeTargets.Field, Inherited = false)]
[ComVisibleAttribute(true)]
public sealed class NonSerializedAttribute : Attribute

AttributeTargets.Field tells you that it can be used on the fields and is not inheritable

So you have to use it on the fields that you don't want to be serializable.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top