Blog » C# » creating simple calculator using c#

creating simple calculator using c#

This article will show you how to make very simple calculator application using windows forms c#. this script can add, multiply,subtract,division etc.

source code


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Calculater
{
  public partial class Form1 : Form
  {
    public Form1()
    {
    InitializeComponent();
    }
    private void button1_Click(object sender, EventArgs e)
    {
    int x = int.Parse(txtn1.Text);
    int y = int.Parse(txtn2.Text);
    int result = x + y;
    lblResult.Text = " Result: " + result;
		}
    private void btnSubtract_Click(object sender, EventArgs e)
    {
    int x = int.Parse(txtn1.Text);
    int y = int.Parse(txtn2.Text);
    int result = x - y;
    lblResult.Text = " Result: " + result;
    }
    private void btnMultiply_Click(object sender, EventArgs e)
    {
    int x = int.Parse(txtn1.Text);
    int y = int.Parse(txtn2.Text);
    int result = x * y;
    lblResult.Text = " Result: " + result;
    }
    private void btnDivision_Click(object sender, EventArgs e)
    {
    int x = int.Parse(txtn1.Text);
    int y = int.Parse(txtn2.Text);
    int result = x / y;
    lblResult.Text = " Result: " + result;

    }
  }
}
ARTICLE POSTED BY : Admin

Hi, I'am k.g uththara. I'm a professional web developer. I write blog posts in my free time. if you want to contact me, send a message on contact page, thanks.