本文整理汇总了C#中Circle.Area方法的典型用法代码示例。如果您正苦于以下问题:C# Circle.Area方法的具体用法?C# Circle.Area怎么用?C# Circle.Area使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Circle
的用法示例。
在下文中一共展示了Circle.Area方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
Console.Title = "计算圆形的面积";
Circle circle = new Circle(10) ; //创建一个半径为10的圆形实例
Console.WriteLine("半径为{0}的圆形面积为{1}", circle.Radius,circle.Area());//输出圆形面积
Console.Read();
}
示例2: Main
static void Main()
{
double r = 3.0, h = 5.0;
Shape c = new Circle(r);
Shape s = new Sphere(r);
Shape l = new Cylinder(r, h);
// Display results:
Console.WriteLine("Area of Circle = {0:F2}", c.Area());
Console.WriteLine("Area of Sphere = {0:F2}", s.Area());
Console.WriteLine("Area of Cylinder = {0:F2}", l.Area());
}
示例3: Main
public static void Main()
{
double r = 3.0, h = 5.0;
Dimensions c = new Circle(r);
Dimensions s = new Sphere(r);
Dimensions l = new Cylinder(r, h);
Console.WriteLine("Area of Circle = {0}", string.Format("{0:0.00}", c.Area()));
Console.WriteLine("Area of Sphere = {0}", string.Format("{0:0.00}", s.Area()));
Console.WriteLine("Area of Cylinder = {0}", string.Format("{0:0.00}", l.Area()));
Console.ReadLine();
}
示例4: testClass
// 类
public void testClass()
{
MyClass p1 = new MyClass();
MyClass p2 = new MyClass(6, 7);
Console.WriteLine("CoOrds #1 at {0}", p1);
Console.WriteLine("CoOrds #2 at {0}", p2);
Circle ring = new Circle(2);
Cylinder tube = new Cylinder(2, 3);
Console.WriteLine("Area of the circle = {0:F2}", ring.Area());
Console.WriteLine("Area of the cylinder = {0:F2}", tube.Area());
TimePeriod ti = new TimePeriod(3600*5);
Console.WriteLine("Setid time is {0}", ti.hours);
ShapeStatic.TestSe();
}
示例5: Main
static void Main()
{
double radius = 2.5;
double height = 3.0;
Circle ring = new Circle(radius);
Cylinder tube = new Cylinder(radius, height);
Console.WriteLine("Area of the circle = {0:F2}", ring.Area());
Console.WriteLine("Area of the cylinder = {0:F2}", tube.Area());
// Keep the console window open in debug mode.
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}
示例6: Main
static void Main(string[] args)
{
Circle circle = new Circle();
circle.Radius = 6;
Console.WriteLine(circle.Area());
}
示例7: Main
static void Main(string[] args)
{
List<TwoDim> twodim = new List<TwoDim>();
List<ThreeDim> threedim = new List<ThreeDim>();
while (true)
{
Console.WriteLine("도형종류 : Triangle, Square, Circle, Cube, Sphere");
double number;
Console.Write("단위 크기 : ");
try
{
number = Double.Parse(Console.ReadLine());
if (number<=0)
{
Console.WriteLine("잘못된 범위의 값을 입력하였습니다.");
continue;
}
}
catch (System.FormatException x)
{
Console.WriteLine(x.Message);
continue;
}
catch (SystemException y)
{
Console.WriteLine(y.Message);
continue;
}
Console.Write("모양 : ");
string whatShape = Console.ReadLine();
int count = 0;
int i = 0;
if (whatShape != "Triangle" && whatShape != "Square" && whatShape != "Circle"&&whatShape!="Cube"&&whatShape!="Sphere")
{
Console.WriteLine("없는 도형입니다.");
continue;
}
else if (whatShape == "Triangle")
{
TwoDim tri = new Triangle();
foreach (var item in twodim)
{
if (twodim[i].typeTwo == 3 && twodim[i].numTwo == number)
{
Console.WriteLine("이미 담은 도형입니다.");
count += 1;
break;
}
i++;
}
if (count == 0)
{
tri.typeTwo = 3;
tri.numTwo = number;
tri.Length(number);
tri.Area(number);
twodim.Add(tri);
i = 0;
}
count = 0;
}
else if (whatShape == "Square")
{
TwoDim squ = new Square();
foreach (var item in twodim)
{
if (twodim[i].typeTwo == 4 && twodim[i].numTwo == number)
{
Console.WriteLine("이미 담은 도형입니다.");
count += 1;
break;
}
i++;
}
if (count == 0)
{
squ.typeTwo = 4;
squ.numTwo = number;
squ.Length(number);
squ.Area(number);
twodim.Add(squ);
i = 0;
}
count = 0;
}
else if (whatShape == "Circle")
{
TwoDim cir = new Circle();
foreach (var item in twodim)
{
if (twodim[i].typeTwo == 0 && twodim[i].numTwo == number)
{
Console.WriteLine("이미 담은 도형입니다.");
count += 1;
break;
}
i++;
}
//.........这里部分代码省略.........