471,610 Members | 1,327 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,610 software developers and data experts.

serialization on static values

Hello
Im having trouble serializing a static value inside an object and
deserialize it correctly.
Heres how it works

The idea is that i make lots of objects that has unique IDs, but each object
share one value and that is the ID of the last object created. This way i
know what the ID of the next object will be. So lets say 10 objects share
one value (static).
I create 10 objects and the static variable= 10. on all thos objects...

Now i serialize these objects inside a List<T>.
And close the application. Then i start the application and load in the
objects i serilized, but the problem is that the static value is reset, its
= 0....

That means that the static value did not serialize like the rest of the
objects.
How can i fix this? that my Shared value is saved.

When i load the 10 objects i want that share variable to be 10 and not 0.

thank you.
Feb 21 '06 #1
2 1175
Remember, serialization is serializing instances of the objects. Static data
is not serialized because it's not instance data and there's really no way
to "automatically" do it.

Either store the count somewhere or after you load all the objects, set the
value to the highest ID.

Pete

"Deleo" <De***@noemail.noemail> wrote in message
news:eg**************@TK2MSFTNGP11.phx.gbl...
Hello
Im having trouble serializing a static value inside an object and
deserialize it correctly.
Heres how it works

The idea is that i make lots of objects that has unique IDs, but each
object share one value and that is the ID of the last object created. This
way i know what the ID of the next object will be. So lets say 10 objects
share one value (static).
I create 10 objects and the static variable= 10. on all thos objects...

Now i serialize these objects inside a List<T>.
And close the application. Then i start the application and load in the
objects i serilized, but the problem is that the static value is reset,
its = 0....

That means that the static value did not serialize like the rest of the
objects.
How can i fix this? that my Shared value is saved.

When i load the 10 objects i want that share variable to be 10 and not 0.

thank you.

Feb 21 '06 #2
ok thanks
Ill work around it then....
just wanted to know if I could serialize the thing :)

"Deleo" <De***@noemail.noemail> wrote in message
news:eg**************@TK2MSFTNGP11.phx.gbl...
Hello
Im having trouble serializing a static value inside an object and
deserialize it correctly.
Heres how it works

The idea is that i make lots of objects that has unique IDs, but each
object share one value and that is the ID of the last object created. This
way i know what the ID of the next object will be. So lets say 10 objects
share one value (static).
I create 10 objects and the static variable= 10. on all thos objects...

Now i serialize these objects inside a List<T>.
And close the application. Then i start the application and load in the
objects i serilized, but the problem is that the static value is reset,
its = 0....

That means that the static value did not serialize like the rest of the
objects.
How can i fix this? that my Shared value is saved.

When i load the 10 objects i want that share variable to be 10 and not 0.

thank you.

Feb 22 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Mike Frayn | last post: by
4 posts views Thread by ron | last post: by
5 posts views Thread by Arjen | last post: by
6 posts views Thread by Uttam | last post: by
6 posts views Thread by Polo | last post: by
3 posts views Thread by Paulo Morgado [MVP] | last post: by
reply views Thread by JosAH | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by CCCYYYY | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.