Name

NonSerializedAttribute

Synopsis

This attribute lets you mark properties of fields in a class as nonserializable, so that they are ignored during a serialization operation. Typical examples of nonserializable data include pointers, handles, and other data structures that can’t be recreated during deserialization.

By default, a class is not eligible for serialization unless it implements System.Runtime.Serialization.ISerializable or is marked with a SerializableAttribute. Once a class is marked as serializable, you must mark all fields or properties that are not to be serialized with a NonSerializedAttribute.

public sealed class NonSerializedAttribute : Attribute {
// Public Constructors
   public method NonSerializedAttribute();  
}

Hierarchy

ObjectAttributeNonSerializedAttribute

Valid On

Field

Get C# in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.