0
嗨,我是全新的mirosoft視覺工作室,我想創建一個基本的圓形,但我有以下錯誤:不能將類型'雙'轉換爲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);
}
}
}
是否有可能只做雙打?我嘗試了這種方式,但然後我在我的最後一行「paper.DrawEllipse(筆,0,周長,面積,體積)有一個錯誤;」說它必須是詮釋。 – mrName
你也必須在其他部分也加上括號 – MikeB
謝謝大家回答我的問題,你們都幫助我解決了我的問題,我真的讚賞你在解決我的問題時付出的努力和時間;) – mrName