c# inheritance call base constructor code example
Example 1: c# class inheritance constructor
public otherclass{
public otherclass(a,b){
a=0;
b=1;
}
}
public baseClass : otherclass{
public baseClass(string str,int a, int b): base(a,b){
str="whatever";
}
}
Example 2: c# superclass constructor
public Vehicle( double speed )
{
Speed = speed;
LicensePlate = Tools.GenerateLicensePlate();
}
class Sedan
{
public Sedan(double speed)
{
Speed = speed;
LicensePlate = Tools.GenerateLicensePlate();
Wheels = 4;
}
class Sedan : Vehicle
{
public Sedan(double speed) : base(speed)
{
Wheels = 4;
}
}