using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Retangle {
//成员变量
double length;
double width;
public void InitPar() {
length = 4.5;
width = 3.5;
}
public double GetArea() {
return length * width;
}
public void Display() {
Console.WriteLine("Length:{0}",length);
Console.WriteLine("Width:{0}", width);
Console.WriteLine("Area:{0}", GetArea());
}
}
class Program
{
//Main方法的要求
//Main必须定义为static
//Main的首字母必须大写
//返回值可以是void或者是int
//命令行参数可选
static void Main(string[] args)
{
Retangle r = new Retangle();
r.InitPar();
r.Display();
Console.ReadLine();
}
}
}
07-18
546
07-17
629