Polymorphism

From Logic Wiki
Revision as of 09:56, 13 June 2017 by AliIybar (Talk | contribs) (public int Width{get; set;})

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

public class Circle : Shape
{
}

public class Rectangle : Shape 
{
}

public class Shape 
{

}