Friday, 5 December 2014

Abstract Method in Asp .Net

Abstract Method :-

If method is define as abstract method then it can not contain a implementation but it can forcely allow to derived class to override that method.


 EXAMPLE:-


public abstract class Shape
{
   public abstract void Paint(Graphics g, Rectangle r);
}
public class Ellipse: Shape
{
   public override void Paint(Graphics g, Rectangle r) {
      g.DrawEllipse(r);
   }
}
public class Box: Shape
{
   public override void Paint(Graphics g, Rectangle r) {
      g.DrawRect(r);
   }
}

No comments:

Post a Comment