Connecting Tech Pros Worldwide Forums | Help | Site Map

Static fields and Serialization

antoan
Guest
 
Posts: n/a
#1: Jun 27 '06
I'm trying to understand why static fields are not serializable in
general. Is it purely because of implementation reasons or because it
does not make sense to do this?








Jon Skeet [C# MVP]
Guest
 
Posts: n/a
#2: Jun 27 '06

re: Static fields and Serialization


antoan <antoan@antoan.plus.com> wrote:[color=blue]
> I'm trying to understand why static fields are not serializable in
> general. Is it purely because of implementation reasons or because it
> does not make sense to do this?[/color]

Serialization persists the state of a single object. Static fields are
not part of the state of an object - they're effectively the state of
the type.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
antoan
Guest
 
Posts: n/a
#3: Jun 28 '06

re: Static fields and Serialization


Jon Skeet [C# MVP] wrote:[color=blue]
> antoan <antoan@antoan.plus.com> wrote:[color=green]
>> I'm trying to understand why static fields are not serializable in
>> general. Is it purely because of implementation reasons or because it
>> does not make sense to do this?[/color]
>
> Serialization persists the state of a single object. Static fields are
> not part of the state of an object - they're effectively the state of
> the type.
>[/color]
Thanks Jon, exactly what I was looking for.

A
Closed Thread