编程学习网为您整理以下代码实例,主要实现:C#基本语法,希望可以帮到各位朋友。
using System;
namespace RectangleApplication {
class Rectangle {
// member variables
double length;
double wIDth;
public voID Acceptdetails() {
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 ExecuteRectangle {
static voID Main(string[] args) {
Rectangle r = new Rectangle();
r.Acceptdetails();
r.display();
Console.Readline();
}
}
}
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!