Monday, May 26, 2014

class inheritance with public override string and observable collection

You're not calling the appropriate base constructor from your derived classes constructors. If you do not call the base constructor the compiler will attempt to call the default constructor (the one with no arguments) for you but such a constructor does not exist in your classes.


Here's how to fix Parts1 and Parts1A. Parts1B is left as a homework :)



public class Parts1 : Parts
{
public Parts1(string nme, Type typ)
: base(nme) // add this
{
types = typ;
}
}

public class Parts1A : Parts1
{
public Parts1A(string nme, Type typ, int num)
: base(nme, typ) // add this
{
number = num;
}
}

No comments:

Post a Comment