本文整理汇总了C#中Polygon.GetArea方法的典型用法代码示例。如果您正苦于以下问题:C# Polygon.GetArea方法的具体用法?C# Polygon.GetArea怎么用?C# Polygon.GetArea使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polygon
的用法示例。
在下文中一共展示了Polygon.GetArea方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
Console.Write("Enter the number of points of the polygon: ");
int pointsCount = int.Parse(Console.ReadLine());
Point[] points = new Point[pointsCount];
for (int i = 0; i < pointsCount; i++)
{
points[i] = Point.Parse(Console.ReadLine());
}
Polygon polygon = new Polygon(points);
Console.WriteLine("Perimeter: {0:F2}", polygon.GetPerimeter());
Console.WriteLine("Area: {0:F2}", polygon.GetArea());
}
示例2: Main
static void Main()
{
Console.Write("n = ");
int n = int.Parse(Console.ReadLine());
Console.WriteLine("Now enter {0} points (described with their coordiantes (x and y) :", n);
string[] values;
List<Point> points = new List<Point>();
for (int i = 0; i < n; i++)
{
values = Console.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
points.Add(new Point(double.Parse(values[0]), double.Parse(values[1])));
}
Polygon poly = new Polygon(points);
Console.WriteLine("\nperimetre = {0:f2}\narea = {1:f2}", poly.GetPerimetre(), poly.GetArea());
}