[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 298
  • 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
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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