Benefits of [NonSerialized] when [Serializable] is not used
问题 I'm looking through some existing code in a project I'm working on, and I found a class that is implemented as: public class ThingOne { private int A; private int B; [NonSerialized] private System.Timers.Timer timer1; } Shouldn't it look more like this? [Serializable] public class ThingOne { private int A; private int B; [NonSerialized] private System.Timers.Timer timer1; } Or is there some additional benefit to adding [NonSerialized] even when the class itself is not Serializable? 回答1: