嗨,我是 mirosoft Visual Studio 的新手,我想创建一个基本圆圈,但出现以下错误:无法将类型“double”隐式转换为 int。存在显式转换。(你错过了演员吗?)
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 WindowsFormsApplication6
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int radius = Convert.ToInt32(textBox1.Text);
int circumference = 2 * Math.PI * radius;
int area = Math.PI * Math.Pow(radius, 2);
int volume = (4 * Math.PI / 3) * Math.Pow(radius, 3);
Graphics paper;
paper = pictureBox1.CreateGraphics();
Pen pen = new Pen(Color.Red);
paper.DrawEllipse(pen, 0, circumference, area, volume);
}
}
}