• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 299
  • Last Modified:

Serialization of a Derived Class

When serializing a derived class, the members in its base class are serialized too, correct?
If so, does the base class have to have [Serializable] attribute too?
0
metro156
Asked:
metro156
  • 3
  • 3
1 Solution
 
käµfm³d 👽Commented:
What kind of serialization? Binary? XML?
0
 
metro156Author Commented:
Binary
0
 
käµfm³d 👽Commented:
Yes, the base class must be marked as Serializable as well.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
metro156Author Commented:
So are you saying if base class is not Serialized, program will not compile or runtime error?

Or  Are you saying --if you only Serialize the derived class, the data declared only within the derived class be serialized?
0
 
käµfm³d 👽Commented:
If you serialize the derived class, you will get an exception stating that the base class needs the attribute as well:

Screenshot
0
 
metro156Author Commented:
Thank you
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now