您的位置:首页 > 编程语言 > C#

C#基本语法-实现在控制台输出矩形的长宽面积

2017-03-30 17:42 253 查看
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();

}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: