当前位置: 首页>>代码示例>>C#>>正文


C# Circle.Area方法代码示例

本文整理汇总了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();
        }
开发者ID:dalinhuang,项目名称:wdeqawes-efrwserd-rgtedrtf,代码行数:8,代码来源:Program.cs

示例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());
 }
开发者ID:terryjintry,项目名称:OLSource1,代码行数:11,代码来源:virtual--csharp-reference-_2.cs

示例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();
    }
开发者ID:Nagato23,项目名称:CsBasic,代码行数:13,代码来源:virtualTest.cs

示例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();
        }
开发者ID:howard1982,项目名称:csharp,代码行数:20,代码来源:Program.cs

示例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();
    }
开发者ID:robertmirro,项目名称:csharp-sandbox,代码行数:15,代码来源:ConstructorTest.cs

示例6: Main

 static void Main(string[] args)
 {
     Circle circle = new Circle();
     circle.Radius = 6;
     Console.WriteLine(circle.Area());
 }
开发者ID:xuzhiwei1989,项目名称:BookTest,代码行数:6,代码来源:Program.cs

示例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++;
                    }
//.........这里部分代码省略.........
开发者ID:ahu8867,项目名称:Lab_20150715_shape,代码行数:101,代码来源:Program.cs


注:本文中的Circle.Area方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。