current position:Home>Please answer the questions about # C #!

Please answer the questions about # C #!

2022-02-04 16:41:45 CSDN Q & A

img

Beginners C# Be more detailed




Take the answer :

img

using System;namespace ConsoleApp1{    public class Circle    {        /// <summary>        ///  radius         /// </summary>        public double R { get; set; }        public static int nums { get; set; }        public Circle(int R) {            this.R = R;            Circle.nums++;        }        public double Area() {            return Math.PI * Math.Pow(R,2);        }    }    class Program    {        static void Main(string[] args) {            var circle = new Circle(5);            Console.WriteLine(" area :" + circle.Area());            Console.WriteLine(" Number of round real cases :" + Circle.nums);            circle = new Circle(6);            Console.WriteLine(" area :" + circle.Area());            Console.WriteLine(" Number of round real cases :" + Circle.nums);            Console.ReadKey();        }    }}

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/02/202202041641441095.html

Random recommended