Hman,
You should be able to serialize instances like this:
PageList pl = new PageList();
// populate pl
XmlSerializer ser = new XmlSerializer( typeof( PageList ), new Type[] {
... } ); // enumerate all the types in the list.
ser.Serialize( writer, pl );
be careful though ... if you don't know what the types in your List are,
then getting the Types from the list elements and instantiating a serializer
instance is a very expensive operation and if performance matters, then you
should probably alter your design to not go that route.
I also have a few questions about the PageList class. Why do you implement
everything by hand, is there any reason you don't derive from CollectionBase
or ? And why are you even implementing a custom List if you don't strongly
type it? You may just as well stick to the ArrayList.

Signature
HTH
Christoph Schittko [MVP, XmlInsider]
Software Architect, .NET Mentor
> Hi,
>
[quoted text clipped - 49 lines]
>
> How do I serialized this class?
Hi, thanks for your help.
Actually, I have another class (Survey) which has an
instance of my PageList class.
code segment:
public class Survey
{
//survey has a collection of pages
private PageList _pagesCol;
private Page _currentPage;
public Survey()
{
_pagesCol = new PageList();
Page defaultFirstPage = new Page();
defaultFirstPage.Name = "Page 1";
_pagesCol.Add (defaultFirstPage);
}
}
I am simply serializing an intance of Survey:
// Serialization
XmlSerializer s = new XmlSerializer(typeof(Survey));
TextWriter w = new StreamWriter(@"C:\SCSurvey.xml");
s.Serialize(w, _survey);
w.Close();
where _survey is my Survey instance created elsewhere.
Why isn't my PageList intance serialized?
-
-I don't know what strongly types custom lists are.
>-----Original Message-----
>Hman,
[quoted text clipped - 74 lines]
>
>.
Got everything working. Thanks.
>-----Original Message-----
>Hi, thanks for your help.
[quoted text clipped - 123 lines]
>>
>.