标签:
尝试开发一个程序,要求自定义一个结构,该结构中包含圆的半径及圆面积的方法,然后在main方法中调用自定义的结构求指定半径的圆面积。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace p148_1
{
class circle
{
const double pi = 3.1415926;
private float r = 0;
private float s = 0;
public float cr
{
get
{
return r;
}
set
{
r = value;
}
}
public float cs
{
get
{
return s;
}
set
{
s = value;
}
}
public double area()
{
return (pi * r * r);
}
}
class Program
{
static void Main(string[] args)
{
circle mycircle = new circle();
mycircle.cr = 10;
mycircle.area();
Console.WriteLine(mycircle.area());
Console.ReadLine();
}
}
}
标签:
原文地址:http://www.cnblogs.com/stonelei/p/5021576.html