Polymorphism

From Logic Wiki
Revision as of 13:19, 15 September 2014 by Macrop (Talk) (Created page with "Category:OOP Category:Extreme Programming Category:CSharp if you want to use a method or property of a base class differently in child classes you need polymorphi...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


if you want to use a method or property of a base class differently in child classes you need polymorphism.

Simply add virtual keyword to base class's method

public virtual void Gazla(int ivme)
{
 this.Hiz += ivme;
}

in child class

public override void Gazla(int icme)
{
 // base.Gazla // to use base method as it is
  this.hiz += 2 * ivme;
}