Abstract Property Declaration द्वारा Property Accessors का Implementation Provide नहीं किया जाएगा।
आइए देखते हैं कि Abstract Properties के साथ कैसे काम करें। यहां हमारे पास एक Abstract Class Shape है जिसके दो Derived Classes हैं: Square और Circle।
यहां, हमारे पास एक Abstract Area Property है।
निम्न Circle Class है।
Example
public class Circle : Shape { private int radius; public Circle(int radius, string id) : base(id) { this.radius = radius; } public override double Area { get { return radius * radius * System.Math.PI; } } }इसी तरह, Square Class।
Example
public class Square : Shape { private int side; public Square(int side, string id) : base(id) { this.side = side; } public override double Area { get { return side * side; } } }निम्न Shape Class है, जो Abstract है।
Example
public abstract class Shape { private string name; public Shape(string s) { Id = s; } public string Id { get { return name; } set { name = value; } } public abstract double Area { get; } public override string ToString() { return Id + " Area = " + string.Format("{0:F2}", Area); } }