using System;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization.Formatters.Soap;

[Serializable]
class Employee
{
	public Employee ()
	{
	}
	private int id;
	public int Id
	{
		get
		{
			return id;
		}
		set
		{
			id = value;
		}
	}
	private string name;
	public string Name
	{
		get
		{
			return name;
		}
		set
		{
			name = value;
		}
	}

	public static void Main()
	{
		// create the object to serialize
		Employee e = new Employee();
		e.id = 987654321;
		e.Name = "John Doe";

		// use a binary formatter

		BinaryFormatter formatter1 = new BinaryFormatter();
		formatter1.Context = 
			new StreamingContext(StreamingContextStates.CrossMachine);
		FileStream stream1 = new FileStream("Demo.rem", FileMode.Create);
		formatter1.Serialize(stream1, e);
		stream1.Close();

		// use the SOAP formatter

		SoapFormatter formatter2 = new SoapFormatter();
		formatter2.Context = 
			new StreamingContext(StreamingContextStates.CrossMachine);
		FileStream stream2 = new FileStream("Demo.soap", FileMode.Create);
		formatter2.Serialize(stream2, e);
		stream2.Close();

	}
}