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;
namespace demo1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string r = textBox1.Text.Trim(); // 将输入的圆半径赋给字符串r
double DouR = Convert.ToDouble(r); // 将字符类型转换为数值类型
const double PI = 3.1415926; // 定义圆周率
label1.Text = "圆的面积为:" + PI * DouR * DouR; // 计算圆面积并输出
}
}
}