public class Rect
{
public Rect(){}
public Rect(double w, double h)
{
this.width = w;
this.height = h;
}
private double width;
private double height;
public double Width
{
get{return width;}
set{width=value;}
}
public double Height
{
get{return height;}
set{height=value;}
}
//面积
public double Area
{
get{Width*Height;}
}
}
static void Main(string[] args)
{
Rect r = new Rect(20,30);
Console.WriteLine(r.Area);
}
把Main中的内容修改成你控件的名字就行了。