Mono Class Library: System Namespace

System.SerializableAttribute Class

Marks a type as being serializable. [Edit]

See Also: SerializableAttribute Members

System.Object
     System.Attribute
          System.SerializableAttribute

[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Struct | System.AttributeTargets.Enum | System.AttributeTargets.Delegate | System.AttributeTargets.All, AllowMultiple=false, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class SerializableAttribute : Attribute

Remarks

This attribute indicates that the class it's being applied to is serializable. This is a requirement for all classes in an object's graph that is being serialized. A System.Runtime.Serialization.SerializationException is thrown if a class without the SerializableAttribute is serialized.
C# Example
using System;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Soap;

public class SerializationDemo {
	public static void Main()  {
		Point pt = new Point();
		pt.x=1;
		pt.y=2;

		Console.WriteLine(pt);
		
		SoapFormatter formatter = new SoapFormatter();
		// Serialize out to STDOUT.
		formatter.Serialize(System.Console.OpenStandardOutput(), pt);
	}
}

[Serializable()]
public class Point {
	public int x,y;		// Serialize This
	
	[NonSerialized()]	// Don't serialize Visible attribute
	public bool Visible=false;
	
	public override string ToString(){	// Methods aren't serialized
		return String.Format("({0},{1})",x,y);
	}
}
  
[Edit]

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0