Is public declaration a requirement for a class to be serializable? I’ve been going through some code where all classes marked as [Serializable] were also declared public. I could not find formal documentation stating this.
Is public declaration a requirement for a class to be serializable? I’ve been going
Share
No, there is no such requirement for
Serializable. It’s not surprising that you seeSerializableon public classes, since data that’s going to be persisted to a stream is very likely to be shared with others, and therefore motivates the choice of a public class.