https://www.dropbox.com/s/7rp6l45bythx9v7/Ads%C4%B1z.png
alan_cevre isimli form ekranmız
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 alan_cevre
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
///
/// construction olarak alanı bulduk
///
///
///
private void button1_Click(object sender, EventArgs e)
{
Class1 rectangle = new Class1();
MessageBox.Show(rectangle.alan(Convert.ToInt16(textBox1.Text), Convert.ToInt16(textBox2.Text)).ToString());
}
///
/// parametreli fonksiyon olarak çevreyi hesapladık
///
///
///
private void button2_Click(object sender, EventArgs e)
{
Class1 rectangle=new Class1(Convert.ToInt16(textBox1.Text), Convert.ToInt16(textBox2.Text));
MessageBox.Show( rectangle.environmental().ToString());
}
}
}
Class1 isimli Classımız
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace alan_cevre
{
public class Class1
{
public int En { get; set; }
public int Boy { get; set; }
public Class1()
{
}
public Class1(int en,int boy)
{
En = en;
Boy = boy;
}
public int alan(int en, int boy)
{
return en * boy;
}
public int alan()
{
return En * Boy;
}
public int environmental()
{
return (En+Boy)*2;
}
public int environmental(int en, int boy)
{
return 2 * (en + boy);
}
}
}
kolay gelsin