Serializable()

M

Morten Snedker

<Serializable()> Public Class Dealer

What does Serializable do?




Regards /Snedker
 
A

Aidy

It allows another object to convert your object's properties into a form
that can be transmitted, saved etc and then re-created. As an object is
basically a bunch of binary data you can't do much with it beyond your
existing app.

Marking your object as serialisable means it can be stored in the viewstate,
stored in the session if you're not using in-proc sessions, can be sent via
remoting, web methods etc. What happens is that the object's data is stored
in a property bag type thing, that property bag is saved somewhere
(viewstate, session etc) or sent (remoting etc) then the receiving code will
deserialise the object by creating a new instance of one and setting its
properties as dictated by the property bag. So in psuedo code;

//Take object's property values and store in the viewstate
ViewState ["myObject"] = myObject;

// Create new instance of object, read the property values are read from the
viewstate
// and populate the new object with them
myObject = (MyObjectType) ViewState["myObject"];

The two objects *look* the same as they have the same property values, but
they are not the actual same binary object.
 
B

bruce barker

thats what serialization does.

setting the Serializable attribute means the object will successfully
serialize if asked to. either the object implements ISerializable or
follows all the rules for the default serialization logic to work.

-- bruce (sqlwork.com)
It allows another object to convert your object's properties into a form
that can be transmitted, saved etc and then re-created. As an object is
basically a bunch of binary data you can't do much with it beyond your
existing app.

Marking your object as serialisable means it can be stored in the viewstate,
stored in the session if you're not using in-proc sessions, can be sent via
remoting, web methods etc. What happens is that the object's data is stored
in a property bag type thing, that property bag is saved somewhere
(viewstate, session etc) or sent (remoting etc) then the receiving code will
deserialise the object by creating a new instance of one and setting its
properties as dictated by the property bag. So in psuedo code;

//Take object's property values and store in the viewstate
ViewState ["myObject"] = myObject;

// Create new instance of object, read the property values are read from the
viewstate
// and populate the new object with them
myObject = (MyObjectType) ViewState["myObject"];

The two objects *look* the same as they have the same property values, but
they are not the actual same binary object.

Morten Snedker said:
<Serializable()> Public Class Dealer

What does Serializable do?




Regards /Snedker
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,167
Messages
2,570,911
Members
47,453
Latest member
MadelinePh

Latest Threads

Top