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

serializing iderived classes in arrays

P: n/a

Hi all,

I have an ArrayList that contains items of type A. I declared the
XmlArrayItem atribute for that type.

Now I have an derived type B (from A) also contained in the ArrayList
but I get an error when serializing.

Can this be made without redeclaring the ArrayList special attributes?
The problem is that the class B is in different namespace!
public class Container
[XmlArray, XmlArrayItem(typeof(A))]
public ArrayList Items = new ArrayList();

public class A
public string Name = "A object";
public A()

--- (different namespace!) -----
public class B : A
public B()
Name = "B object";

I think I could use XmlAttributeOverrides but this way I'll have to
change the serializing code every time I derive a new class from A. :(

That's me favorite shirt. That's me only shirt!
Nov 12 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.