derived class and base class c# code example

Example 1: how to get derived class from base class C#

class Base {
	[...]
}

class Derived : Base {
	[...]
}

/* if an instance of the base class is derived you will be able to
cast that instance to it's derrived class, as such: */

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;
        }
    }