Constructor Parameters and Inheritance

As to why you can’t do:

public SubClass(string SubString) : base(BaseString)

What would BaseString be?

You could do:

public SubClass(string SubString) : base("SomeFixedString")

or

public SubClass(string SubString) : base(SubString)

But if you want to pass one string to the base class constructor’s parameter and have an additional one, you’ll need to accept two parameters.

As to keeping the same name, you don’t. You could do:

public SubClass(string AnotherString, string SubString) : base(AnotherString)

As to the last question, the first parameter isn’t doing nothing, it’s being passed to the base class constructor. You could use it for something else if you wanted to.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)