public void TestSerialization()
    {
        BinarySerialization.SampleClass obj = new BinarySerialization.SampleClass(10, "hello");
        Stream          a  = File.OpenWrite("C:\\abc.bin");
        BinaryFormatter bf = new BinaryFormatter();

        bf.Serialize(a, obj);
        a.Close();
    }
    public void TestDeserialization()
    {
        FileStream file = new FileStream("C:\\abc.bin",
                                         FileMode.Open);

        BinaryFormatter bf = new BinaryFormatter();

        BinarySerialization.SampleClass obj = bf.Deserialize(file) as BinarySerialization.SampleClass;
        if (obj != null)
        {
            Console.WriteLine("Object Value (" + obj.Value + ") Buffer (" + obj.Buffer + ")");
        }
        else
        {
            Console.WriteLine("could not read");
        }
        file.Close();
    }