Static fields and Serialization

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • antoan

    Static fields and Serialization

    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]

    #2
    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.co m>
    http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
    If replying to the group, please do not mail me too

    Comment

    • antoan

      #3
      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

      Comment

      Working...