using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class rectangle
{
//定义成员变量
double length;
double width;
public void canshu()
{
length = 4.6;
width = 3;
}
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 Executerectangle
{
static void Main(string []arges)
{
rectangle r = new rectangle();
r.canshu();
r.Display();
Console.ReadKey();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class rectangle
{
//定义成员变量
double length;
double width;
public void canshu()
{
length = 4.6;
width = 3;
}
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 Executerectangle
{
static void Main(string []arges)
{
rectangle r = new rectangle();
r.canshu();
r.Display();
Console.ReadKey();
}
}
}