By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,670 Members | 1,563 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,670 IT Pros & Developers. It's quick & easy.

Serialization of a complex structure

P: n/a
Hello,

Anyone got any good examples of how to serialize a nested class?

My outer class has got ArrayList members for inner classes, each with
their own data. I need to serialise the lot into an xml file for easy
load/save.
Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Phil,

Must the format be human-readable? If not, I recommend using the
BinaryFormatter or SoapFormatter (I believe this is depricated or frozen for
..NET 2.0) instead of the XmlSerializer.

Nested classes are classes whose type definition is located in a class.
It doesn't matter for serialization purposes because an instance of that
type will be like any other type.

If you mean private references in the instance, then XML serialization
isn't going to help, as it only serializes what is publically accessible.

You are better off using traditional serialization for the more complex
structures.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Phil Da Lick!" <ph***********@NOSPAM.hotmail.com> wrote in message
news:42*********************@ptn-nntp-reader03.plus.net...
Hello,

Anyone got any good examples of how to serialize a nested class?

My outer class has got ArrayList members for inner classes, each with
their own data. I need to serialise the lot into an xml file for easy
load/save.

Nov 16 '05 #2

P: n/a
Nicholas Paldino [.NET/C# MVP] wrote:
Phil,

Must the format be human-readable? If not, I recommend using the
BinaryFormatter or SoapFormatter (I believe this is depricated or frozen for
.NET 2.0) instead of the XmlSerializer.

Nested classes are classes whose type definition is located in a class.
It doesn't matter for serialization purposes because an instance of that
type will be like any other type.

If you mean private references in the instance, then XML serialization
isn't going to help, as it only serializes what is publically accessible.

You are better off using traditional serialization for the more complex
structures.


Perhaps I didnt phrase it right. My collections are what is worrying me.
How would I modify the serialization to include them?

And more importantly, in the deserialization process the right classes
will have to be created. One of the collections in particular will
contain up to eight different classes.
Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.