抽象屬性:
using System;
abstract class Shape
{
public abstract int Area { get; }
}
class Rectangle : Shape
{
private int FWidth, FHeight;
public Rectangle(int w, int h)
{
FWidth = w;
FHeight = h;
}
public override int Area
{
get { return FWidth * FHeight; }
}
}
class Program
{
static void Main()
{
Rectangle Rect = new Rectangle(20, 10);
Console.WriteLine(Rect.Area); // 200
Console.ReadKey();
}
}