471,594 Members | 1,835 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,594 software developers and data experts.

serializing iderived classes in arrays

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
0 1204

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Aleksei Guzev | last post: by
4 posts views Thread by Wayne Wengert | last post: by
1 post views Thread by Ivo Bronsveld | last post: by
2 posts views Thread by Tobias Zimmergren | last post: by
2 posts views Thread by farseer | last post: by
8 posts views Thread by Joe | last post: by
2 posts views Thread by Simon | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.