I get the error:
Error 1 Too many arguments to 'Public Sub New()"
This surprises me because I thought that if a constructor is not defined in the subclass, S, that the base class constructor method, specifically, the one with the single integer param would be invoked w/o an error.
Do you have any idea why I am getting this error? Are constructors a special case?
The constructor for a class only applies to the class it's defined in, even in an inheritance relationship. To be able to take advantage of your base-class 1-arg constructor, you'd have to do something like this (in C#):
public class S : B
{
public S()
{
// do something for S
}
public S(int myInt) : base(myInt)
{
// do something for S
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With