Have you noted that when you create a constructor for a base class with any parameters you get a compiler error? So for example this gives an error:
namespace Constructors
{
class Program
{
static void Main(string[] args)
{
}
}
class MyTestClass
{
public MyTestClass(int testValue1, int testValue2)
{
}
}
class MyOtherTestClass : MyTestClass
{
}
}
Error 1 ‘Constructors.MyTestClass’ does not contain a constructor that takes ’0′ arguments
To fix this error you have to use the base keyword like this:
class MyOtherTestClass : MyTestClass
{
public MyOtherTestClass(int testVal1, int testVal2)
: base(testVal1, testVal2)
{
}
}
Place your comment