Untitled

 avatar
unknown
plain_text
5 months ago
1.3 kB
4
Indexable
 private TextBox txt;
 private TextBox txt2;
 private Label lbl;

 public Form1()
 {
     InitializeComponent();
 }

 internal void Form1_Load(object sender, EventArgs e)
 {

     Button btn = new Button();
     btn.Location = new Point(10, 0);
     btn.Text = "Hesapla";
     btn.Click += btn_Click;
     this.Controls.Add(btn);

     // TextBox oluşturma
     txt = new TextBox();
     txt2 = new TextBox();

     txt.Location = new Point(0, 30);
     txt2.Location = new Point(0, 80);

     this.Controls.Add(txt);
     this.Controls.Add(txt2);

     // Label oluşturma
     lbl = new Label();
     lbl.Location = new Point(10, 120);
     lbl.Text = "Sonuç: ";
     this.Controls.Add(lbl);
 }

 internal void btn_Click(object sender, EventArgs e)
 {

     // TextBox'lardan değerleri al
     double sayi1 = Convert.ToDouble(txt.Text);
     double sayi2 = Convert.ToDouble(txt2.Text);

     // Toplama işlemini yap
     Hesap hesap = new Hesap();
     double toplam = hesap.Topla(sayi1, sayi2);

     // Sonucu Label'a yazdır
     lbl.Text = "Sonuç: " + toplam.ToString();

 }

 public class Hesap
 {
     public double Topla(double t1, double t2)
     {
         return t1 + t2;
     }
 }
Editor is loading...
Leave a Comment