O'Reilly logo

C# in a Nutshell by Peter Drayton, Ted Neward, Ben Albahari

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required