Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How To Serialize Object

Status
Not open for further replies.

ronenhm

Programmer
Dec 20, 2001
43
IL
Hello,

i like to know how i can Serialize an object to string
or binary data so i can pass it over network...

and then De-Serialize the object again

the object can be from any kind and contain any kind of data...

C# code Example will be greate for me to understand
thanks ronen.
 
Start off with this:

ms-help://MS.VSCC/MS.MSDNVS/cpguide/html/cpovrserializingobjects.htm

The short summary:
Mark your class with the [Serializable] attribute

Declare a formatter:
IFormatter formatter = new BinaryFormatter();

Call one of the serialize overloaded methods on the formatter:
formatter.Serialize(stream, obj);

Chip H.
 
Hi
thanks for your response

can i serialize an object that i don't have its source code?
i have a class that is a SAPTable object developed by SAP compeny so i can't mark it as Serializeable
however i do wan't to pass it as stream over the network to another system

can it be done?

NOTE: when i returned this object from WebService and invoke the function from the explorer the response was the object in xml format
how can i do what the explorer did to that object?

thanks ronen.
 
Try the call to the formatter anyway - SAP might have already put the attribute on there for their own purposes.

There are several formatters available - there's also an XML formatter, plus you can write your own.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top