C# 矩形面积 0002

来源:互联网 发布:cv source数据库 复旦 编辑:程序博客网 时间:2024/05/20 10:12
using System;namespace RectangleApplication{    class Rectangle    {        // member variables        double length;        double width;        double area;        /* public void Acceptdetails()         {             length = 4.5;             width = 3.5;         }         */        public double GetArea()        {            length = 4.5;            width = 3.5;            area = length * width;            return area;        }        public void Display()        {            Console.WriteLine("Length: {0}", length);            Console.WriteLine("Width: {0}", width);            Console.WriteLine("Area: {0}", GetArea());        }    }    class ExecuteRectangle    {        static void Main(string[] args)        {            Rectangle r = new Rectangle();            // r.Acceptdetails();            r.Display();            Console.ReadLine();        }    }} 

output:
Length: 0
Width: 0
Area: 15.75

0 0
原创粉丝点击