What does your implementation of the custom collection look like ? Your custom collection implement an indexer, something like (adapted from the C# Programmer's Reference):
public Foobar this [int index] // indexer declaration { get { // Check the index limits if (index < 0 || index >= 100) return 0; else return myArray[index]; } set { if (!(index < 0 || index >= 100)) myArray[index] = value; } } HTH, Christoph Schittko Software Architect Mshow - a division of InterCall ----- Original Message ----- From: "Jeff Knutson" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, May 22, 2002 2:57 PM Subject: [DOTNET] Serializing collectionbase into xml > Hi > > Could someone please help me figure out how to do xml serialization of a > custom collection derived from CollectionBase? I have gotten this to work > for ArrayList, but would much rather have my own custom collection. > > e.g. > > [XmlRoot( "Foo", Namespace="http://www.foo.com", IsNullable = false) ] > class Foo > { > private Foobars foobars = new Foobars(); > [XmlArrayItem( ElementName="Foobar", Type=typeof(Foobar) )] > public Foobars Foobars > { > get{ return this.foobars; } > } > } > > class Foobars : CollectionBase > {} > > [XmlRoot( "Foobar", Namespace="http://www.foo.com", ElementName="Foobar", > IsNulllable = false) ] > class Foobar > { > public int i; > public short s; > } > > When try to create an instance of the XmlSerializer, i am getting an > InvalidOperationException : There was an error reflecting Foo. Here is > the code for that: > > XmlSerializer s = new XmlSerializer( typeof( Foo ) ); > > > Thanks in advance for the help. :) > Jeff > > You can read messages from the DOTNET archive, unsubscribe from DOTNET, or > subscribe to other DevelopMentor lists at http://discuss.develop.com. You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.