using System;
namespace HelloWorldApplication
{
class shape{
protected int width;
protected int height;
public void Width(int w){
width=w;
}
public void Height(int h){
height=h;
}
}
class rectangle:shape{
public int getarea(){
return (width*height);
}
}
class rectangletester{
static void Main(string[] args){
rectangle rec=new rectangle();
rec.Width(2);
rec.Height(3);
Console.WriteLine("面积是{0}",rec.getarea());
Console.ReadLine();
}
}
}
方法后记得加括号