، این برنامه نوشتم خطا میده برام این برنامه خیلی مهمه می شود خواهشا راهنمایی کنید . برنامه ای طول عرض مستطیلی ومربعی را خوانده محیط ومساحت مستطیل ومربع رامحاسبه می کند؟
namespace area
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent()
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
comboBox1.SelectedIndex = 0
}
private void button1_Click(object sender, EventArgs e)
{
Rectangle rect = new Rectangle()
rect.width =Convert.ToInt16(textBox1.Text)
rect.Height=Convert.ToInt16(textBox2.Text)
rect. button1Area()
rect.button1perime()
label3.Text =Area =+(rect. getArea).ToString()
label3.Text +=
label3.Text +=+perime=+(rect. get perime).ToString()
}
}
}
-
namespace area
{
class Rectangle
{
private int width// width of rectangle
private int height // height of rectangle
private int area
private int perime //perime of rectangle
private int Width
//width property
public int width
{
get
{
return width
}
set
{
width = value
}
}
//height property
public int Height
{
get
{
return height
}
set
{
height = value
}
}
//method button1Area
public void button1Area()
{
area = Width * height
}
//method button-1area perime
public void button1perime()
{
perime=(Width + height) * 2
}
//method get Area
public int get Area ()
{
return Area
}
//method get Perime
public int getPerime()
{
return perime
}
}