Serializable()

  • Thread starter Thread starter Morten Snedker
  • Start date Start date
M

Morten Snedker

<Serializable()> Public Class Dealer

What does Serializable do?




Regards /Snedker
 
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.
 
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
 
Back
Top