Serialization: Convert the object to byte [] and then to string. You can convert an object to a convertible format.
Public byte [] serializable_data (Object OBJ)
{
Iformatter formatter = new binaryformatter ();
Memorystream MS = new memorystream ();
Byte [] B;
Formatter. serialize (MS, OBJ );
Ms. Position = 0;
B = new byte [Ms. Length];
Ms. Read (B, 0, B. Length );
Ms. Close ();
Return B;
}
/// <Summary>
/// Convert the byte array into ASCII characters
/// </Summary>
Public String serializable_data (byte [] _ data)
{
Return convert. tobase64string (_ data );
}
Deserialization: Convert string to byte []-> object.
Public static object deserialize_data (string data)
{
Byte [] bytarray = convert. frombase64string (data );
Iformatter formatter = new binaryformatter ();
Memorystream MS = new memorystream ();
Ms. Write (bytarray, 0, bytarray. Length );
Ms. Position = 0;
Object OBJ = (object) formatter. deserialize (MS );
Return OBJ;
}
Web Service: website service
The Web Service can pass an object, but it must be serialized. Then the client references the server and deserializes the object after instantiation.
Before class serialization, you must add [serializable]