derived class and base class c# code example
Example 1: how to get derived class from base class C#
class Base {
[...]
}
class Derived : Base {
[...]
}
Base baseInstance = new Derived();
Derived derivedFromInstance = (Derived)baseInstance;
Example 2: Base class c#
class Motore:Veicoli
{
public bool Cavalletto { get; set; }
public Motore (String marca, String modello, int cilindrata, bool cavalletto): base (marca,modello,cilindrata)
{
this.Cavalletto = cavalletto;
}
override
public void Accelera(double velocitacorrente )
{
this.VelocitaCorrente += velocitacorrente;
}
}