示例#1
0
        static void Main(string[] args)
        {
            FileStream       fileStream         = new FileStream(@"g:\\MySoapFile.dat", FileMode.Open);
            SoapFormatter    formatter          = new SoapFormatter();
            AddSerialization deserializedSample = (AddSerialization)formatter.Deserialize(fileStream);

            Console.WriteLine("The deserialized object:");
            Console.WriteLine(String.Format("Name: {0}", deserializedSample.Name));
            Console.WriteLine(String.Format("Value: {0}", deserializedSample.Age.ToString()));

            Console.Read();
        }
        static void Main(string[] args)
        {
            AddSerialization sample = new AddSerialization();

            sample.Name = "Surendra";
            sample.Age  = 24;
            FileStream    fileStream = new FileStream(@"g:\\MySoapFile.dat", FileMode.Create);
            SoapFormatter formatter  = new SoapFormatter();

            formatter.Serialize(fileStream, sample);
            Console.WriteLine("serialized successfully");
            Console.Read();
        }