代码参考:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace WindowsCircleArea.Lib { public class Circle { private int radius; public Circle(int r) { radius = r; } public double GetArea() { return Math.PI * radius * radius; } public double Area { get { return Math.PI * radius * radius; } } } }
参考代码2:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using WindowsCircleArea.Lib; namespace WindowsCircleArea { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void btnArea_Click(object sender, EventArgs e) { int iOutR = int.Parse(txtOutR.Text); int iInR1 = int.Parse(txtInR1.Text); int iInR2 = int.Parse(txtInR2.Text); Circle outCircle = new Circle(iOutR); Circle inCircle1 = new Circle(iInR1); Circle inCircle2 = new Circle(iInR2); double area = outCircle.Area-inCircle1.Area -inCircle2.Area; lblArea.Text = "蓝色水域的面积是:"+area.ToString(); pB.Image = Properties.Resources.c1; } private void Form1_Load(object sender, EventArgs e) { pB.Image = Properties.Resources.c1; } private void txtOutR_Enter(object sender, EventArgs e) { pB.Image = Properties.Resources.c2; } private void txtInR1_Enter(object sender, EventArgs e) { pB.Image = Properties.Resources.c3; } private void txtInR2_Enter(object sender, EventArgs e) { pB.Image = Properties.Resources.c4; } } }
标签:C#,System,private,Windows,int,窗体,using,Circle,public From: https://www.cnblogs.com/exesoft/p/16991446.html