sub class construtor, super class not holding value

  • Thread starter Thread starter Martin
  • Start date Start date
M

Martin

Hi,

I've got a base/super class with just a default constructor. I want another
constructor, but I can't modify the base class, so I created a sub class
with a constructor like so:

public class MySub:MyBase
{
public MySub(string val):base()
{
base.public1="String";
base.public2=val;
}
}

I use it like so:

MyBase myBase=new MySub("sometext");

The class MySub then has no direct references to it, but there is still a
reference to the sub class.

What I'm finding is that if I look at the the value of myBase.public1
under debug (immediately after the assignment has executed), it says Error:
Cannot obtain value, and furthermore, when I try to serialize this class
using XmlSerializer I get an exception:

"An unhandled exception of type 'System.InvalidOperationException' occurred
in system.xml.dll

Additional information: There was an error generating the XML document."



Can someone help me solve the problem?

Thanks

Martin
 
Although the debugger and xmlserializer don't like it, I can correctly
write the base class values to the console.

I reckon this is a xmlserializer issue.

Martin
 
Back
Top