SerializableAttribute Class
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
Indicates that a class can be serialized. This class cannot be inherited.
Inheritance Hierarchy
System. . :: . .Object
System. . :: . .Attribute
System..::..SerializableAttribute
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
<AttributeUsageAttribute(AttributeTargets.Class Or AttributeTargets.Struct Or AttributeTargets.Enum Or AttributeTargets.Delegate, Inherited := False)> _
Public NotInheritable Class SerializableAttribute _
Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Enum|AttributeTargets.Delegate, Inherited = false)]
public sealed class SerializableAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class|AttributeTargets::Struct|AttributeTargets::Enum|AttributeTargets::Delegate, Inherited = false)]
public ref class SerializableAttribute sealed : public Attribute
[<Sealed>]
[<AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Enum|AttributeTargets.Delegate, Inherited = false)>]
type SerializableAttribute =
class
inherit Attribute
end
public final class SerializableAttribute extends Attribute
The SerializableAttribute type exposes the following members.
Constructors
Name | Description | |
---|---|---|
SerializableAttribute | Initializes a new instance of the SerializableAttribute class. |
Top
Methods
Name | Description | |
---|---|---|
Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Top
Remarks
Apply the SerializableAttribute attribute to a type to indicate that instances of this type can be serialized. The common language runtime throws SerializationException if any type in the graph of objects being serialized does not have the SerializableAttribute attribute applied.
Apply the SerializableAttribute attribute even if the class also implements the ISerializable interface to control the serialization process.
When you apply the SerializableAttribute attribute to a type, all private and public fields are serialized by default. You can control serialization more granularly by implementing the ISerializable interface to override the serialization process.
Or you can exclude fields from serialization by applying the NonSerializedAttribute attribute to the field. If a field of a serializable type contains a pointer, a handle, or some other data structure that is specific to a particular environment, and cannot be meaningfully reconstituted in a different environment, then you might want to apply the NonSerializedAttribute attribute to that field.
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.