本文整理汇总了C#中Square.GetArea方法的典型用法代码示例。如果您正苦于以下问题:C# Square.GetArea方法的具体用法?C# Square.GetArea怎么用?C# Square.GetArea使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Square
的用法示例。
在下文中一共展示了Square.GetArea方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
HondaAccord danielsCar = new HondaAccord();
ChevySilverado casonsdreamCar = new ChevySilverado();
Ford150 tomsCar = new Ford150();
Car[] cars = new Car[3];
cars[0] = danielsCar;
cars[1] = casonsdreamCar;
cars[2] = tomsCar;
IStoppable[] vehicles = new IStoppable[3];
vehicles[0] = danielsCar;
vehicles[1] = casonsdreamCar;
//vehicles[2] = tomsCar;
foreach (var v in vehicles)
{
v.Brake();
}
Square s = new Square();
s.LengthOfSide = 10;
Triangle t = new Triangle();
t.LengthOfSide = 5;
//Polygon p = new Polygon();
//p.NumberOfSides = 6;
//p.LengthOfSide = 10;
var areaOfP = s.GetArea();
Console.WriteLine($"The area is {areaOfP} for this {s.GetShapeName()}. # of sides: {s.NumberOfSides}. Length of Sides: {s.LengthOfSide}");
var areaOfP2 = t.GetArea();
Console.WriteLine($"The area is {areaOfP2} for this {t.GetShapeName()}. # of sides: {t.NumberOfSides}. Length of Sides: {t.LengthOfSide}");
Console.ReadLine();
}